BJ Lazy Load - Version 0.5.1

Version Description

Download this release

Release Info

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

Code changes from version 0.5.0 to 0.5.1

Files changed (5) hide show
  1. admin.php +18 -0
  2. bj-lazy-load.php +20 -8
  3. js/bj-lazy-load.js +1 -1
  4. js/bj-lazy-load.min.js +1 -1
  5. readme.txt +5 -1
admin.php CHANGED
@@ -13,6 +13,24 @@ class BJLL_Admin_Page extends scbAdminPage {
13
 
14
 
15
  echo $this->form_table( array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  array(
17
  'title' => __( 'Lazy load images', 'bj_lazy_load' ),
18
  'type' => 'radio',
13
 
14
 
15
  echo $this->form_table( array(
16
+ array(
17
+ 'title' => __( 'Apply to content', 'bj_lazy_load' ),
18
+ 'type' => 'radio',
19
+ 'name' => 'filter_content',
20
+ 'value' => array( 'yes' => __('Yes', 'bj_lazy_load'), 'no' => __('No', 'bj_lazy_load') ),
21
+ ),
22
+ array(
23
+ 'title' => __( 'Apply to post thumbnails', 'bj_lazy_load' ),
24
+ 'type' => 'radio',
25
+ 'name' => 'filter_post_thumbnails',
26
+ 'value' => array( 'yes' => __('Yes', 'bj_lazy_load'), 'no' => __('No', 'bj_lazy_load') ),
27
+ ),
28
+ array(
29
+ 'title' => __( 'Apply to gravatars', 'bj_lazy_load' ),
30
+ 'type' => 'radio',
31
+ 'name' => 'filter_gravatars',
32
+ 'value' => array( 'yes' => __('Yes', 'bj_lazy_load'), 'no' => __('No', 'bj_lazy_load') ),
33
+ ),
34
  array(
35
  'title' => __( 'Lazy load images', 'bj_lazy_load' ),
36
  'type' => 'radio',
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.5.0
7
  Author: Bjørn Johansen
8
  Author URI: http://twitter.com/bjornjohansen
9
  License: GPL2
@@ -31,7 +31,7 @@ require_once( dirname(__FILE__) . '/scb/load.php' );
31
  if ( ! class_exists( 'BJLL' ) ) {
32
  class BJLL {
33
 
34
- const version = '0.5.0';
35
  protected $_placeholder_url;
36
 
37
  protected static $_instance;
@@ -42,9 +42,18 @@ if ( ! class_exists( 'BJLL' ) ) {
42
 
43
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
44
 
45
- add_filter( 'the_content', array( $this, 'filter' ), 200 );
46
- add_filter( 'post_thumbnail_html', array( $this, 'filter' ), 200 );
47
- add_filter( 'get_avatar', array( $this, 'filter' ), 200 );
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  static function singleton() {
@@ -143,9 +152,12 @@ if ( ! class_exists( 'BJLL' ) ) {
143
 
144
  protected function _get_options() {
145
  return new scbOptions( 'bj_lazy_load_options', __FILE__, array(
146
- 'lazy_load_images' => 'yes',
147
- 'lazy_load_iframes' => 'yes',
148
- 'theme_loader_function' => 'wp_footer'
 
 
 
149
  ) );
150
  }
151
 
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.5.1
7
  Author: Bjørn Johansen
8
  Author URI: http://twitter.com/bjornjohansen
9
  License: GPL2
31
  if ( ! class_exists( 'BJLL' ) ) {
32
  class BJLL {
33
 
34
+ const version = '0.5.1';
35
  protected $_placeholder_url;
36
 
37
  protected static $_instance;
42
 
43
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
44
 
45
+ $options = self::_get_options();
46
+
47
+
48
+ if ( $options->get('filter_content') == 'yes' ) {
49
+ add_filter( 'the_content', array( $this, 'filter' ), 200 );
50
+ }
51
+ if ( $options->get('filter_post_thumbnails') == 'yes' ) {
52
+ add_filter( 'post_thumbnail_html', array( $this, 'filter' ), 200 );
53
+ }
54
+ if ( $options->get('filter_gravatars') == 'yes' ) {
55
+ add_filter( 'get_avatar', array( $this, 'filter' ), 200 );
56
+ }
57
  }
58
 
59
  static function singleton() {
152
 
153
  protected function _get_options() {
154
  return new scbOptions( 'bj_lazy_load_options', __FILE__, array(
155
+ 'filter_content' => 'yes',
156
+ 'filter_post_thumbnails' => 'yes',
157
+ 'filter_gravatars' => 'yes',
158
+ 'lazy_load_images' => 'yes',
159
+ 'lazy_load_iframes' => 'yes',
160
+ 'theme_loader_function' => 'wp_footer'
161
  ) );
162
  }
163
 
js/bj-lazy-load.js CHANGED
@@ -73,6 +73,6 @@
73
  return dec;
74
  }
75
 
76
- $( document ).on( 'ready', bj_lazy_load_init );
77
 
78
  })(jQuery);
73
  return dec;
74
  }
75
 
76
+ $( document ).bind( 'ready', bj_lazy_load_init ); // using .on is more efficient, but requires jQuery 1.7
77
 
78
  })(jQuery);
js/bj-lazy-load.min.js CHANGED
@@ -1 +1 @@
1
- (function(c){function b(){c(".lazy-hidden").not("[data-lazy-ready]").one("scrollin.bj_lazy_load",{distance:200},function(){var d=c(this),e=d.attr("data-lazy-type");if(e=="image"){d.attr("src",d.attr("data-lazy-src")).removeClass("lazy-hidden")}else{if(e=="iframe"){d.replaceWith(a(d.attr("data-lazy-src")))}}}).attr("data-lazy-ready","true")}function a(l){var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var f,e,d,p,o,n,m,q,k=0,r=0,h="",j=[];if(!l){return l}l+="";do{p=g.indexOf(l.charAt(k++));o=g.indexOf(l.charAt(k++));n=g.indexOf(l.charAt(k++));m=g.indexOf(l.charAt(k++));q=p<<18|o<<12|n<<6|m;f=q>>16&255;e=q>>8&255;d=q&255;if(n==64){j[r++]=String.fromCharCode(f)}else{if(m==64){j[r++]=String.fromCharCode(f,e)}else{j[r++]=String.fromCharCode(f,e,d)}}}while(k<l.length);h=j.join("");return h}c(document).on("ready",b)})(jQuery);
1
+ (function($){function bj_lazy_load_init(){$('.lazy-hidden').not('[data-lazy-ready]').one('scrollin.bj_lazy_load',{distance:200},function(){var $el=$(this),data_lazy_type=$el.attr('data-lazy-type');if(data_lazy_type=='image'){$el.attr('src',$el.attr('data-lazy-src')).removeClass('lazy-hidden')}else if(data_lazy_type=='iframe'){$el.replaceWith(bj_lazy_load_base64_decode($el.attr('data-lazy-src')))}}).attr('data-lazy-ready','true')}function bj_lazy_load_base64_decode(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,dec="",tmp_arr=[];if(!data){return data}data+='';do{h1=b64.indexOf(data.charAt(i++));h2=b64.indexOf(data.charAt(i++));h3=b64.indexOf(data.charAt(i++));h4=b64.indexOf(data.charAt(i++));bits=h1<<18|h2<<12|h3<<6|h4;o1=bits>>16&0xff;o2=bits>>8&0xff;o3=bits&0xff;if(h3==64){tmp_arr[ac++]=String.fromCharCode(o1)}else if(h4==64){tmp_arr[ac++]=String.fromCharCode(o1,o2)}else{tmp_arr[ac++]=String.fromCharCode(o1,o2,o3)}}while(i<data.length);dec=tmp_arr.join('');return dec}$(document).bind('ready',bj_lazy_load_init)})(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.4.1
8
- Stable tag: 0.5.0
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
 
@@ -56,6 +56,10 @@ Check your HTML source or see the magic at work in Web Inspector, FireBug or sim
56
 
57
  == Changelog ==
58
 
 
 
 
 
59
  = Version 0.5.0 =
60
  * Complete rewrite
61
  * Replaced JAIL with jQuery.sonar to accomodate for iframe lazy loading
5
  Author URI: http://twitter.com/bjornjohansen
6
  Requires at least: 3.3
7
  Tested up to: 3.4.1
8
+ Stable tag: 0.5.1
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
 
56
 
57
  == Changelog ==
58
 
59
+ = Version 0.5.1 =
60
+ * Lowered jQuery version dependency
61
+ * New options: More granular control on what content to lazy load
62
+
63
  = Version 0.5.0 =
64
  * Complete rewrite
65
  * Replaced JAIL with jQuery.sonar to accomodate for iframe lazy loading