BJ Lazy Load - Version 0.6.10

Version Description

Works with Opera Mini

Download this release

Release Info

Developer bjornjohansen
Plugin Icon 128x128 BJ Lazy Load
Version 0.6.10
Comparing to
See all releases

Code changes from version 0.6.9 to 0.6.10

Files changed (5) hide show
  1. admin.php +6 -0
  2. bj-lazy-load.php +18 -13
  3. js/bj-lazy-load.js +12 -2
  4. js/combined.min.js +1 -1
  5. readme.txt +10 -1
admin.php CHANGED
@@ -60,6 +60,12 @@ class BJLL_Admin_Page extends scbAdminPage {
60
  'type' => 'text',
61
  'name' => 'skip_classes',
62
  'desc' => sprintf( '<p class="description">%s</p>', __( 'Comma separated. Example: "no-lazy, lazy-ignore, image-235"', 'bj_lazy_load' ) ),
 
 
 
 
 
 
63
  )
64
  );
65
 
60
  'type' => 'text',
61
  'name' => 'skip_classes',
62
  'desc' => sprintf( '<p class="description">%s</p>', __( 'Comma separated. Example: "no-lazy, lazy-ignore, image-235"', 'bj_lazy_load' ) ),
63
+ ),
64
+ array(
65
+ 'title' => __( 'Threshold', 'bj_lazy_load' ),
66
+ 'type' => 'text',
67
+ 'name' => 'threshold',
68
+ 'desc' => sprintf( '<p class="description">%s</p>', __( 'How close to the viewport the element should be when we load it. In pixels. Example: 200', 'bj_lazy_load' ) ),
69
  )
70
  );
71
 
bj-lazy-load.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: BJ Lazy Load
4
  Plugin URI: http://wordpress.org/extend/plugins/bj-lazy-load/
5
  Description: Lazy image loading makes your site load faster and saves bandwidth.
6
- Version: 0.6.9
7
  Author: Bjørn Johansen
8
  Author URI: http://twitter.com/bjornjohansen
9
  License: GPL2
@@ -25,22 +25,12 @@ License: GPL2
25
 
26
  */
27
 
28
- function print_filters_for( $hook = '' ) {
29
- global $wp_filter;
30
- if( empty( $hook ) || !isset( $wp_filter[$hook] ) )
31
- return;
32
-
33
- print '<pre>';
34
- print_r( $wp_filter[$hook] );
35
- print '</pre>';
36
- }
37
-
38
  require_once( dirname(__FILE__) . '/scb/load.php' );
39
 
40
  if ( ! class_exists( 'BJLL' ) ) {
41
  class BJLL {
42
 
43
- const version = '0.6.8';
44
  protected $_placeholder_url;
45
  protected $_skip_classes;
46
 
@@ -53,6 +43,11 @@ if ( ! class_exists( 'BJLL' ) ) {
53
  return;
54
  }
55
 
 
 
 
 
 
56
  $options = self::_get_options();
57
 
58
  if ( 'yes' == $options->get( 'disable_on_wptouch' ) && self::is_wptouch() ) {
@@ -120,11 +115,20 @@ if ( ! class_exists( 'BJLL' ) ) {
120
  $bjll_options['thumb_base'] = plugins_url( '/thumb.php', __FILE__ ) . '?src=';
121
  $bjll_options['load_hidpi'] = $options->get('load_hidpi');
122
  $bjll_options['load_responsive'] = $options->get('load_responsive');
 
 
 
 
 
123
  }
124
 
125
  if ( $options->get('infinite_scroll') == 'yes' ) {
126
  $bjll_options['infinite_scroll'] = $options->get('infinite_scroll');
127
  }
 
 
 
 
128
 
129
 
130
  if ( count( $bjll_options ) ) {
@@ -232,7 +236,8 @@ if ( ! class_exists( 'BJLL' ) ) {
232
  'load_responsive' => 'no',
233
  'disable_on_wptouch' => 'yes',
234
  'disable_on_mobilepress' => 'yes',
235
- 'infinite_scroll' => 'no'
 
236
  ) );
237
  }
238
 
3
  Plugin Name: BJ Lazy Load
4
  Plugin URI: http://wordpress.org/extend/plugins/bj-lazy-load/
5
  Description: Lazy image loading makes your site load faster and saves bandwidth.
6
+ Version: 0.6.10
7
  Author: Bjørn Johansen
8
  Author URI: http://twitter.com/bjornjohansen
9
  License: GPL2
25
 
26
  */
27
 
 
 
 
 
 
 
 
 
 
 
28
  require_once( dirname(__FILE__) . '/scb/load.php' );
29
 
30
  if ( ! class_exists( 'BJLL' ) ) {
31
  class BJLL {
32
 
33
+ const version = '0.6.10';
34
  protected $_placeholder_url;
35
  protected $_skip_classes;
36
 
43
  return;
44
  }
45
 
46
+ // Disable on Opera Mini
47
+ if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) !== false ) {
48
+ return;
49
+ }
50
+
51
  $options = self::_get_options();
52
 
53
  if ( 'yes' == $options->get( 'disable_on_wptouch' ) && self::is_wptouch() ) {
115
  $bjll_options['thumb_base'] = plugins_url( '/thumb.php', __FILE__ ) . '?src=';
116
  $bjll_options['load_hidpi'] = $options->get('load_hidpi');
117
  $bjll_options['load_responsive'] = $options->get('load_responsive');
118
+
119
+ if ( is_multisite() ) {
120
+ $bjll_options['site_url'] = get_site_url();
121
+ $bjll_options['network_site_url'] = network_site_url();
122
+ }
123
  }
124
 
125
  if ( $options->get('infinite_scroll') == 'yes' ) {
126
  $bjll_options['infinite_scroll'] = $options->get('infinite_scroll');
127
  }
128
+
129
+ if ( intval( $options->get('threshold') ) != 200 ) {
130
+ $bjll_options['threshold'] = intval( $options->get('threshold') );
131
+ }
132
 
133
 
134
  if ( count( $bjll_options ) ) {
236
  'load_responsive' => 'no',
237
  'disable_on_wptouch' => 'yes',
238
  'disable_on_mobilepress' => 'yes',
239
+ 'infinite_scroll' => 'no',
240
+ 'threshold' => '200'
241
  ) );
242
  }
243
 
js/bj-lazy-load.js CHANGED
@@ -5,7 +5,13 @@ var BJLL = BJLL || {};
5
 
6
  function bj_lazy_load_init() {
7
 
8
- $('.lazy-hidden').not('.data-lazy-ready').one( 'scrollin.bj_lazy_load', { distance: 200 }, function() {
 
 
 
 
 
 
9
 
10
  var $el = $( this ),
11
  data_lazy_type = $el.attr( 'data-lazy-type' );
@@ -23,7 +29,11 @@ var BJLL = BJLL || {};
23
  if ( window.devicePixelRatio > 1 && BJLL.load_hidpi == 'yes' ) {
24
  loadimgwidth = Math.ceil( window.devicePixelRatio * loadimgwidth );
25
  }
26
- imgurl = BJLL.thumb_base + escape( $el.attr( 'data-lazy-src' ) ) + '&w=' + loadimgwidth;
 
 
 
 
27
  }
28
 
29
  }
5
 
6
  function bj_lazy_load_init() {
7
 
8
+ var threshold = 200;
9
+
10
+ if ( 'undefined' != typeof ( BJLL.threshold ) ) {
11
+ threshold = parseInt( BJLL.threshold );
12
+ }
13
+
14
+ $('.lazy-hidden').not('.data-lazy-ready').one( 'scrollin.bj_lazy_load', { distance: threshold }, function() {
15
 
16
  var $el = $( this ),
17
  data_lazy_type = $el.attr( 'data-lazy-type' );
29
  if ( window.devicePixelRatio > 1 && BJLL.load_hidpi == 'yes' ) {
30
  loadimgwidth = Math.ceil( window.devicePixelRatio * loadimgwidth );
31
  }
32
+ var srcimgurl = $el.attr( 'data-lazy-src' );
33
+ if ( 'undefined' != typeof ( BJLL.site_url ) && 'undefined' != typeof ( BJLL.network_site_url ) ) {
34
+ srcimgurl = srcimgurl.replace( BJLL.site_url, BJLL.network_site_url );
35
+ }
36
+ imgurl = BJLL.thumb_base + escape( srcimgurl ) + '&w=' + loadimgwidth;
37
  }
38
 
39
  }
js/combined.min.js CHANGED
@@ -1 +1 @@
1
- (function(e,t,n,r){e.fn.sonar=function(t,n){if(typeof t==="boolean"){n=t;t=r}return e.sonar(this[0],t,n)};var i=n.body,s=e(t),o="scrollin",u="scrollout",a=function(e,s,o){if(e){i||(i=n.body);var u=e,a=0,f=i.offsetHeight,l=t.innerHeight||n.documentElement.clientHeight||i.clientHeight||0,c=n.documentElement.scrollTop||t.pageYOffset||i.scrollTop||0,h=e.offsetHeight||0;if(!e.sonarElemTop||e.sonarBodyHeight!==f){if(u.offsetParent){do{a+=u.offsetTop}while(u=u.offsetParent)}e.sonarElemTop=a;e.sonarBodyHeight=f}s=s===r?0:s;return!(e.sonarElemTop+(o?0:h)<c-s)&&!(e.sonarElemTop+(o?h:0)>c+l+s)}},f={},l=0,c,h=function(){c&&clearTimeout(c);c=setTimeout(function(){var t,n,r,i,s,o,l;for(r in f){n=f[r];for(o=0,l=n.length;o<l;o++){i=n[o];t=i.elem;s=a(t,i.px,i.full);if(r===u?!s:s){if(!i.tr){if(t["_"+r]){e(t).trigger(r);i.tr=1}else{n.splice(o,1);o--;l--}}}else{i.tr=0}}}},0)},p=function(e,t){e["_"+t]=0},d=function(n,r){var i=r.px,c=r.full,p=r.evt,d=t,v=a(n,i,c),m=0;n["_"+p]=1;if(p===u?!v:v){setTimeout(function(){e(n).trigger(p===u?u:o)},0);m=1}f[p].push({elem:n,px:i,full:c,tr:m});if(!l){s.bind("scroll",h);l=1}};e.sonar=a;f[o]=[];e.event.special[o]={add:function(e){var t=e.data||{},n=this;if(!n[o]){d(this,{px:t.distance,full:t.full,evt:o})}},remove:function(e){p(this,o)}};f[u]=[];e.event.special[u]={add:function(e){var t=e.data||{},n=this;if(!n[u]){d(n,{px:t.distance,full:t.full,evt:u})}},remove:function(e){p(this,u)}}})(jQuery,window,document);var BJLL=BJLL||{};(function(e){function t(){e(".lazy-hidden").not(".data-lazy-ready").one("scrollin.bj_lazy_load",{distance:200},function(){var t=e(this),r=t.attr("data-lazy-type");if(r=="image"){var i=t.attr("data-lazy-src");if(BJLL.load_responsive=="yes"||BJLL.load_hidpi=="yes"){var s=document.createElement("a");s.href=t.attr("data-lazy-src");if(!s.hostname.length||s.hostname==window.location.hostname){var o=parseInt(t.css("width"));if(window.devicePixelRatio>1&&BJLL.load_hidpi=="yes"){o=Math.ceil(window.devicePixelRatio*o)}i=BJLL.thumb_base+escape(t.attr("data-lazy-src"))+"&w="+o}}t.hide().attr("src",i).removeClass("lazy-hidden").fadeIn()}else if(r=="iframe"){t.replaceWith(n(t.attr("data-lazy-src")))}}).addClass("data-lazy-ready")}function n(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var n,r,i,s,o,u,a,f,l=0,c=0,h="",p=[];if(!e){return e}e+="";do{s=t.indexOf(e.charAt(l++));o=t.indexOf(e.charAt(l++));u=t.indexOf(e.charAt(l++));a=t.indexOf(e.charAt(l++));f=s<<18|o<<12|u<<6|a;n=f>>16&255;r=f>>8&255;i=f&255;if(u==64){p[c++]=String.fromCharCode(n)}else if(a==64){p[c++]=String.fromCharCode(n,r)}else{p[c++]=String.fromCharCode(n,r,i)}}while(l<e.length);h=p.join("");return h}e(document).bind("ready",t);if(BJLL.infinite_scroll=="yes"){e(window).bind("scroll",t)}e(window).on("resize",function(){e(document).trigger("scroll")})})(jQuery)
1
+ !function(a,b,c,d){a.fn.sonar=function(b,c){return"boolean"==typeof b&&(c=b,b=d),a.sonar(this[0],b,c)};var l,e=c.body,f=a(b),g="scrollin",h="scrollout",i=function(a,f,g){if(a){e||(e=c.body);var h=a,i=0,j=e.offsetHeight,k=b.innerHeight||c.documentElement.clientHeight||e.clientHeight||0,l=c.documentElement.scrollTop||b.pageYOffset||e.scrollTop||0,m=a.offsetHeight||0;if(!a.sonarElemTop||a.sonarBodyHeight!==j){if(h.offsetParent)do i+=h.offsetTop;while(h=h.offsetParent);a.sonarElemTop=i,a.sonarBodyHeight=j}return f=f===d?0:f,!(a.sonarElemTop+(g?0:m)<l-f||a.sonarElemTop+(g?m:0)>l+k+f)}},j={},k=0,m=function(){l&&clearTimeout(l),l=setTimeout(function(){var b,c,d,e,f,g,k;for(d in j)for(c=j[d],g=0,k=c.length;k>g;g++)e=c[g],b=e.elem,f=i(b,e.px,e.full),(d===h?!f:f)?e.tr||(b["_"+d]?(a(b).trigger(d),e.tr=1):(c.splice(g,1),g--,k--)):e.tr=0},0)},n=function(a,b){a["_"+b]=0},o=function(c,d){var e=d.px,l=d.full,n=d.evt,p=i(c,e,l),q=0;c["_"+n]=1,(n===h?!p:p)&&(setTimeout(function(){a(c).trigger(n===h?h:g)},0),q=1),j[n].push({elem:c,px:e,full:l,tr:q}),k||(f.bind("scroll",m),k=1)};a.sonar=i,j[g]=[],a.event.special[g]={add:function(a){var b=a.data||{},c=this;c[g]||o(this,{px:b.distance,full:b.full,evt:g})},remove:function(){n(this,g)}},j[h]=[],a.event.special[h]={add:function(a){var b=a.data||{},c=this;c[h]||o(c,{px:b.distance,full:b.full,evt:h})},remove:function(){n(this,h)}}}(jQuery,window,document);var BJLL=BJLL||{};!function(a){function b(){var b=200;"undefined"!=typeof BJLL.threshold&&(b=parseInt(BJLL.threshold)),a(".lazy-hidden").not(".data-lazy-ready").one("scrollin.bj_lazy_load",{distance:b},function(){var b=a(this),d=b.attr("data-lazy-type");if("image"==d){var e=b.attr("data-lazy-src");if("yes"==BJLL.load_responsive||"yes"==BJLL.load_hidpi){var f=document.createElement("a");if(f.href=b.attr("data-lazy-src"),!f.hostname.length||f.hostname==window.location.hostname){var g=parseInt(b.css("width"));window.devicePixelRatio>1&&"yes"==BJLL.load_hidpi&&(g=Math.ceil(window.devicePixelRatio*g));var h=b.attr("data-lazy-src");"undefined"!=typeof BJLL.site_url&&"undefined"!=typeof BJLL.network_site_url&&(h=h.replace(BJLL.site_url,BJLL.network_site_url)),e=BJLL.thumb_base+escape(h)+"&w="+g}}b.hide().attr("src",e).removeClass("lazy-hidden").fadeIn()}else"iframe"==d&&b.replaceWith(c(b.attr("data-lazy-src")))}).addClass("data-lazy-ready")}function c(a){var c,d,e,f,g,h,i,j,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",k=0,l=0,m="",n=[];if(!a)return a;a+="";do f=b.indexOf(a.charAt(k++)),g=b.indexOf(a.charAt(k++)),h=b.indexOf(a.charAt(k++)),i=b.indexOf(a.charAt(k++)),j=f<<18|g<<12|h<<6|i,c=255&j>>16,d=255&j>>8,e=255&j,n[l++]=64==h?String.fromCharCode(c):64==i?String.fromCharCode(c,d):String.fromCharCode(c,d,e);while(k<a.length);return m=n.join("")}a(document).bind("ready",b),"yes"==BJLL.infinite_scroll&&a(window).bind("scroll",b),a(window).on("resize",function(){a(document).trigger("scroll")})}(jQuery);
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: images, iframes, lazy loading, jquery, javascript, optimize, performance,
5
  Author URI: http://twitter.com/bjornjohansen
6
  Requires at least: 3.3
7
  Tested up to: 3.6
8
- Stable tag: 0.6.9
9
 
10
  Lazy loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users. Works with both images and iframes.
11
 
@@ -60,6 +60,12 @@ Check your HTML source or see the magic at work in Web Inspector, FireBug or sim
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
 
63
  = Version 0.6.9 =
64
  * Bugfix: Single quotes for the class attribute is now handled (thanks @kReEsTaL)
65
  * Bugfix: Removed strict error notice (thanks syndrael)
@@ -166,6 +172,9 @@ Check your HTML source or see the magic at work in Web Inspector, FireBug or sim
166
 
167
  == Upgrade Notice ==
168
 
 
 
 
169
  = 0.6.9 =
170
  Bugfix release
171
 
5
  Author URI: http://twitter.com/bjornjohansen
6
  Requires at least: 3.3
7
  Tested up to: 3.6
8
+ Stable tag: 0.6.10
9
 
10
  Lazy loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users. Works with both images and iframes.
11
 
60
 
61
  == Changelog ==
62
 
63
+ = Version 0.6.10 =
64
+ * Responsive and HiDPI images works with MultiSite subfolders
65
+ * Lazy loading is disabled on Opera Mini
66
+ * Removed leftin print_filters_for() function (sry)
67
+ * User definable threshold
68
+
69
  = Version 0.6.9 =
70
  * Bugfix: Single quotes for the class attribute is now handled (thanks @kReEsTaL)
71
  * Bugfix: Removed strict error notice (thanks syndrael)
172
 
173
  == Upgrade Notice ==
174
 
175
+ = 0.6.10 =
176
+ Works with Opera Mini
177
+
178
  = 0.6.9 =
179
  Bugfix release
180