Version Description
More options and improved non-JS display.
Download this release
Release Info
Developer | bjornjohansen |
Plugin | BJ Lazy Load |
Version | 0.2.2 |
Comparing to | |
See all releases |
Code changes from version 0.2.1 to 0.2.2
- bj-lazy-load.php +74 -20
- css/bjll.css +1 -0
- js/bjll.js +3 -9
- js/bjll.min.js +1 -1
- readme.txt +8 -1
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.2.
|
7 |
Author: Bjørn Johansen
|
8 |
Author URI: http://twitter.com/bjornjohansen
|
9 |
License: GPL2
|
@@ -28,14 +28,22 @@ License: GPL2
|
|
28 |
|
29 |
class BJLL {
|
30 |
|
31 |
-
const version = '0.2.
|
32 |
private $_placeholder_url;
|
33 |
|
34 |
function __construct() {
|
35 |
|
36 |
$this->_placeholder_url = plugins_url('/img/placeholder.gif', __FILE__);
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
add_action( 'wp_ajax_BJLL_get_images', array($this, 'get_images_json') );
|
41 |
add_action( 'wp_ajax_nopriv_BJLL_get_images', array($this, 'get_images_json') );
|
@@ -46,18 +54,22 @@ class BJLL {
|
|
46 |
add_filter( 'post_thumbnail_html', array($this, 'filter_post_thumbnail_html'), 10 );
|
47 |
}
|
48 |
}
|
|
|
|
|
|
|
|
|
49 |
|
50 |
public function enqueue_scripts() {
|
51 |
-
/*
|
52 |
-
wp_enqueue_script('JAIL', plugins_url('/js/jail.min.js', __FILE__), array('jquery'), '0.9.7', true);
|
53 |
-
wp_enqueue_script( 'BJLL', plugins_url('/js/bjll.js', __FILE__), array( 'jquery', 'JAIL' ), self::version, true );
|
54 |
-
*/
|
55 |
-
wp_enqueue_script( 'BJLL', plugins_url('/js/bjll.min.js', __FILE__), array( 'jquery' ), self::version, true );
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
*/
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
wp_localize_script( 'BJLL', 'BJLL', array(
|
62 |
'timeout' => get_option('bjll_timeout', 10),
|
63 |
'effect' => get_option('bjll_effect', 'fadeIn'),
|
@@ -69,7 +81,28 @@ class BJLL {
|
|
69 |
'offset' => get_option('bjll_offset', 200),
|
70 |
'ignoreHiddenImages' => get_option('bjll_ignoreHiddenImages', 0),
|
71 |
) );
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
public function get_images_json() {
|
75 |
echo json_encode($_POST['attachmentIDs']);
|
@@ -108,18 +141,24 @@ class BJLL {
|
|
108 |
protected function _get_placeholder_html ($html) {
|
109 |
|
110 |
$orig_html = $html;
|
111 |
-
|
|
|
112 |
// replace the src and add the data-href attribute
|
113 |
$html = preg_replace( '/<img(.*?)src=/i', '<img$1src="'.$this->_placeholder_url.'" data-href=', $html );
|
114 |
|
115 |
// add the lazy class to the img element
|
116 |
if (preg_match('/class="/i', $html)) {
|
117 |
-
$html = preg_replace('/class="(.*?)"/i', ' class="lazy $1"', $html);
|
118 |
} else {
|
119 |
-
$html = preg_replace('/<img/i', '<img class="lazy"', $html);
|
120 |
}
|
121 |
|
122 |
$html .= '<noscript>' . $orig_html . '</noscript>';
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
return $html;
|
125 |
}
|
@@ -138,14 +177,15 @@ class BJLL_Admin {
|
|
138 |
}
|
139 |
|
140 |
function register_settings() {
|
141 |
-
//register_setting( $option_group, $option_name, $sanitize_callback );
|
142 |
register_setting( 'bjll_options', 'bjll_filter_post_thumbnails', 'intval' );
|
|
|
|
|
143 |
|
144 |
-
//add_settings_section( $id, $title, $callback, $page );
|
145 |
add_settings_section('bjll_general', __('General'), array('BJLL_Admin','settings_section_general'), 'bjll');
|
146 |
|
147 |
-
//add_settings_field( $id, $title, $callback, $page, $section, $args );
|
148 |
add_settings_field('bjll_filter_post_thumbnails', __('Lazy load post thumbnails'), array('BJLL_Admin', 'setting_field_filter_post_thumbnails'), 'bjll', 'bjll_general', array('label_for' => 'bjll_filter_post_thumbnails'));
|
|
|
|
|
149 |
|
150 |
register_setting( 'bjll_options', 'bjll_timeout', 'intval' );
|
151 |
register_setting( 'bjll_options', 'bjll_effect' );
|
@@ -200,14 +240,28 @@ class BJLL_Admin {
|
|
200 |
}
|
201 |
|
202 |
function setting_field_filter_post_thumbnails() {
|
203 |
-
|
204 |
$checked = '';
|
205 |
if (intval(get_option('bjll_filter_post_thumbnails', 1))) {
|
206 |
$checked = ' checked="checked"';
|
207 |
}
|
208 |
|
209 |
echo '<input id="bjll_filter_post_thumbnails" name="bjll_filter_post_thumbnails" type="checkbox" value="1" ' . $checked . ' />';
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
function setting_field_ignoreHiddenImages() {
|
213 |
|
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.2.2
|
7 |
Author: Bjørn Johansen
|
8 |
Author URI: http://twitter.com/bjornjohansen
|
9 |
License: GPL2
|
28 |
|
29 |
class BJLL {
|
30 |
|
31 |
+
const version = '0.2.2';
|
32 |
private $_placeholder_url;
|
33 |
|
34 |
function __construct() {
|
35 |
|
36 |
$this->_placeholder_url = plugins_url('/img/placeholder.gif', __FILE__);
|
37 |
|
38 |
+
if (get_option('bjll_include_css', 1)) {
|
39 |
+
add_action('wp_print_styles', array($this, 'enqueue_styles'));
|
40 |
+
}
|
41 |
+
|
42 |
+
if (get_option('bjll_include_js', 1)) {
|
43 |
+
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
|
44 |
+
}
|
45 |
+
|
46 |
+
add_action('wp_print_footer_scripts', array($this, 'output_js_options'));
|
47 |
|
48 |
add_action( 'wp_ajax_BJLL_get_images', array($this, 'get_images_json') );
|
49 |
add_action( 'wp_ajax_nopriv_BJLL_get_images', array($this, 'get_images_json') );
|
54 |
add_filter( 'post_thumbnail_html', array($this, 'filter_post_thumbnail_html'), 10 );
|
55 |
}
|
56 |
}
|
57 |
+
|
58 |
+
public function enqueue_styles() {
|
59 |
+
wp_enqueue_style( 'BJLL', plugins_url('/css/bjll.css', __FILE__), array(), self::version);
|
60 |
+
}
|
61 |
|
62 |
public function enqueue_scripts() {
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
//wp_enqueue_script('JAIL', plugins_url('/js/jail.min.js', __FILE__), array('jquery'), '0.9.7', true);
|
65 |
+
//wp_enqueue_script( 'BJLL', plugins_url('/js/bjll.js', __FILE__), array( 'jquery', 'JAIL' ), self::version, true );
|
|
|
66 |
|
67 |
+
wp_enqueue_script( 'BJLL', plugins_url('/js/bjll.min.js', __FILE__), array( 'jquery' ), self::version, true );
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
public function output_js_options() {
|
72 |
+
/*
|
73 |
wp_localize_script( 'BJLL', 'BJLL', array(
|
74 |
'timeout' => get_option('bjll_timeout', 10),
|
75 |
'effect' => get_option('bjll_effect', 'fadeIn'),
|
81 |
'offset' => get_option('bjll_offset', 200),
|
82 |
'ignoreHiddenImages' => get_option('bjll_ignoreHiddenImages', 0),
|
83 |
) );
|
84 |
+
*/
|
85 |
+
?>
|
86 |
+
<script type='text/javascript'>
|
87 |
+
/* <![CDATA[ */
|
88 |
+
var BJLL = {
|
89 |
+
options: {
|
90 |
+
timeout: <?php echo intval(get_option('bjll_timeout', 10)); ?>,
|
91 |
+
effect: <?php echo (strlen($val = get_option('bjll_effect', '')) ? '"'.$val.'"' : 'null'); ?>,
|
92 |
+
speed: <?php echo intval(get_option('bjll_speed', 400)); ?>,
|
93 |
+
event: "<?php echo get_option('bjll_event', 'load+scroll'); ?>",
|
94 |
+
callback: "<?php echo get_option('bjll_callback', ''); ?>",
|
95 |
+
placeholder: "<?php echo get_option('bjll_placeholder', ''); ?>",
|
96 |
+
offset: <?php echo intval(get_option('bjll_offset', '')); ?>,
|
97 |
+
ignoreHiddenImages: <?php echo intval(get_option('bjll_ignoreHiddenImages', 0)); ?>
|
98 |
+
|
99 |
+
},
|
100 |
+
ajaxurl: "<?php echo admin_url( 'admin-ajax.php' ); ?>"
|
101 |
+
};
|
102 |
+
/* ]]> */
|
103 |
+
</script>
|
104 |
+
<?php
|
105 |
+
}
|
106 |
|
107 |
public function get_images_json() {
|
108 |
echo json_encode($_POST['attachmentIDs']);
|
141 |
protected function _get_placeholder_html ($html) {
|
142 |
|
143 |
$orig_html = $html;
|
144 |
+
|
145 |
+
/**/
|
146 |
// replace the src and add the data-href attribute
|
147 |
$html = preg_replace( '/<img(.*?)src=/i', '<img$1src="'.$this->_placeholder_url.'" data-href=', $html );
|
148 |
|
149 |
// add the lazy class to the img element
|
150 |
if (preg_match('/class="/i', $html)) {
|
151 |
+
$html = preg_replace('/class="(.*?)"/i', ' class="lazy lazy-hidden $1"', $html);
|
152 |
} else {
|
153 |
+
$html = preg_replace('/<img/i', '<img class="lazy lazy-hidden"', $html);
|
154 |
}
|
155 |
|
156 |
$html .= '<noscript>' . $orig_html . '</noscript>';
|
157 |
+
|
158 |
+
|
159 |
+
|
160 |
+
// http://24ways.org/2011/adaptive-images-for-responsive-designs-again
|
161 |
+
//$html = "<script>document.write('<' + '!--')</script><noscript class=\"lazy-nojs\">" . $orig_html . '<noscript -->';
|
162 |
|
163 |
return $html;
|
164 |
}
|
177 |
}
|
178 |
|
179 |
function register_settings() {
|
|
|
180 |
register_setting( 'bjll_options', 'bjll_filter_post_thumbnails', 'intval' );
|
181 |
+
register_setting( 'bjll_options', 'bjll_include_js', 'intval' );
|
182 |
+
register_setting( 'bjll_options', 'bjll_include_css', 'intval' );
|
183 |
|
|
|
184 |
add_settings_section('bjll_general', __('General'), array('BJLL_Admin','settings_section_general'), 'bjll');
|
185 |
|
|
|
186 |
add_settings_field('bjll_filter_post_thumbnails', __('Lazy load post thumbnails'), array('BJLL_Admin', 'setting_field_filter_post_thumbnails'), 'bjll', 'bjll_general', array('label_for' => 'bjll_filter_post_thumbnails'));
|
187 |
+
add_settings_field('bjll_include_js', __('Include JS'), array('BJLL_Admin', 'setting_field_include_js'), 'bjll', 'bjll_general', array('label_for' => 'bjll_include_js'));
|
188 |
+
add_settings_field('bjll_include_css', __('Include CSS'), array('BJLL_Admin', 'setting_field_include_css'), 'bjll', 'bjll_general', array('label_for' => 'bjll_include_css'));
|
189 |
|
190 |
register_setting( 'bjll_options', 'bjll_timeout', 'intval' );
|
191 |
register_setting( 'bjll_options', 'bjll_effect' );
|
240 |
}
|
241 |
|
242 |
function setting_field_filter_post_thumbnails() {
|
|
|
243 |
$checked = '';
|
244 |
if (intval(get_option('bjll_filter_post_thumbnails', 1))) {
|
245 |
$checked = ' checked="checked"';
|
246 |
}
|
247 |
|
248 |
echo '<input id="bjll_filter_post_thumbnails" name="bjll_filter_post_thumbnails" type="checkbox" value="1" ' . $checked . ' />';
|
249 |
+
}
|
250 |
+
function setting_field_include_js() {
|
251 |
+
$checked = '';
|
252 |
+
if (intval(get_option('bjll_include_js', 1))) {
|
253 |
+
$checked = ' checked="checked"';
|
254 |
+
}
|
255 |
+
|
256 |
+
echo '<input id="bjll_include_js" name="bjll_include_js" type="checkbox" value="1" ' . $checked . ' /> Needed for the plugin to work, but <a href="http://developer.yahoo.com/performance/rules.html#num_http" target="_blank">for best performance you should include it in your combined JS</a>';
|
257 |
+
}
|
258 |
+
function setting_field_include_css() {
|
259 |
+
$checked = '';
|
260 |
+
if (intval(get_option('bjll_include_css', 1))) {
|
261 |
+
$checked = ' checked="checked"';
|
262 |
+
}
|
263 |
+
|
264 |
+
echo '<input id="bjll_include_css" name="bjll_include_css" type="checkbox" value="1" ' . $checked . ' /> Needed for the plugin to work, but <a href="http://developer.yahoo.com/performance/rules.html#num_http" target="_blank">for best performance you should include it in your combined CSS</a>';
|
265 |
}
|
266 |
function setting_field_ignoreHiddenImages() {
|
267 |
|
css/bjll.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.lazy-hidden {display: none !important;}
|
js/bjll.js
CHANGED
@@ -1,11 +1,5 @@
|
|
1 |
(function($) {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
BJLL.speed = parseInt(BJLL.speed);
|
6 |
-
BJLL.ignoreHiddenImages = parseInt(BJLL.ignoreHiddenImages);
|
7 |
-
|
8 |
-
if (!BJLL.effect.length) BJLL.effect = null;
|
9 |
-
|
10 |
-
$('img.lazy').jail(BJLL);
|
11 |
})(jQuery);
|
1 |
(function($) {
|
2 |
+
$(document).ready(function() {
|
3 |
+
$('img.lazy').removeClass('lazy-hidden').jail(BJLL.options);
|
4 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
})(jQuery);
|
js/bjll.min.js
CHANGED
@@ -8,4 +8,4 @@
|
|
8 |
*/
|
9 |
;(function(a){var b=a(window);a.fn.asynchImageLoader=a.fn.jail=function(d){d=a.extend({timeout:10,effect:false,speed:400,selector:null,offset:0,event:"load+scroll",callback:jQuery.noop,callbackAfterEachImage:jQuery.noop,placeholder:false,ignoreHiddenImages:false},d);var c=this;a.jail.initialStack=this;this.data("triggerEl",(d.selector)?a(d.selector):b);if(d.placeholder!==false){c.each(function(){a(this).attr("src",d.placeholder);});}if(/^load/.test(d.event)){a.asynchImageLoader.later.call(this,d);}else{a.asynchImageLoader.onEvent.call(this,d,c);}return this;};a.asynchImageLoader=a.jail={_purgeStack:function(c){var d=0;while(true){if(d===c.length){break;}else{if(c[d].getAttribute("data-href")){d++;}else{c.splice(d,1);}}}},_loadOnEvent:function(g){var f=a(this),d=g.data.options,c=g.data.images;a.asynchImageLoader._loadImageIfVisible(d,f);f.unbind(d.event,a.asynchImageLoader._loadOnEvent);a.asynchImageLoader._purgeStack(c);if(!!d.callback){a.asynchImageLoader._purgeStack(a.jail.initialStack);a.asynchImageLoader._launchCallback(a.jail.initialStack,d);}},_bufferedEventListener:function(g){var c=g.data.images,d=g.data.options,f=c.data("triggerEl");clearTimeout(c.data("poller"));c.data("poller",setTimeout(function(){c.each(function e(){a.asynchImageLoader._loadImageIfVisible(d,this,f);});a.asynchImageLoader._purgeStack(c);if(!!d.callback){a.asynchImageLoader._purgeStack(a.jail.initialStack);a.asynchImageLoader._launchCallback(a.jail.initialStack,d);}},d.timeout));},onEvent:function(d,c){c=c||this;if(d.event==="scroll"||d.selector){var e=c.data("triggerEl");if(c.length>0){e.bind(d.event,{images:c,options:d},a.asynchImageLoader._bufferedEventListener);if(d.event==="scroll"||!d.selector){b.resize({images:c,options:d},a.asynchImageLoader._bufferedEventListener);}return;}else{if(!!e){e.unbind(d.event,a.asynchImageLoader._bufferedEventListener);}}}else{c.bind(d.event,{options:d,images:c},a.asynchImageLoader._loadOnEvent);}},later:function(d){var c=this;if(d.event==="load"){c.each(function(){a.asynchImageLoader._loadImageIfVisible(d,this,c.data("triggerEl"));});}a.asynchImageLoader._purgeStack(c);a.asynchImageLoader._launchCallback(c,d);setTimeout(function(){if(d.event==="load"){c.each(function(){a.asynchImageLoader._loadImage(d,a(this));});}else{c.each(function(){a.asynchImageLoader._loadImageIfVisible(d,this,c.data("triggerEl"));});}a.asynchImageLoader._purgeStack(c);a.asynchImageLoader._launchCallback(c,d);if(d.event==="load+scroll"){d.event="scroll";a.asynchImageLoader.onEvent(d,c);}},d.timeout);},_launchCallback:function(c,d){if(c.length===0&&!a.jail.isCallback){d.callback.call(this,d);a.jail.isCallback=true;}},_loadImageIfVisible:function(e,h,g){var f=a(h),d=(/scroll/i.test(e.event))?g:b,c=true;if(e.ignoreHiddenImages){c=a.jail._isVisibleInOverflownContainer(f,e)&&f.is(":visible");}if(c&&a.asynchImageLoader._isInTheScreen(d,f,e.offset)){a.asynchImageLoader._loadImage(e,f);}},_isInTheScreen:function(j,c,h){var f=j[0]===window,n=(f?{top:0,left:0}:j.offset()),g=n.top+(f?j.scrollTop():0),i=n.left+(f?j.scrollLeft():0),e=i+j.width(),k=g+j.height(),m=c.offset(),l=c.width(),d=c.height();return(g-h)<=(m.top+d)&&(k+h)>=m.top&&(i-h)<=(m.left+l)&&(e+h)>=m.left;},_loadImage:function(c,d){d.hide();d.attr("src",d.attr("data-href"));d.removeAttr("data-href");if(c.effect){if(c.speed){d[c.effect](c.speed);}else{d[c.effect]();}}else{d.show();}c.callbackAfterEachImage.call(this,d,c);},_isVisibleInOverflownContainer:function(e,d){var f=e.parent(),c=true;while(f.get(0).tagName!=="BODY"){if(f.css("overflow")==="hidden"){if(!a.jail._isInTheScreen(f,e,d.offset)){c=false;break;}}if(f.css("visibility")==="hidden"||e.css("visibility")==="hidden"){c=false;break;}f=f.parent();}return c;}};}(jQuery));
|
10 |
/* bjll.js by Bjørn Johansen (@bjornjohansen) */
|
11 |
-
(function($){
|
8 |
*/
|
9 |
;(function(a){var b=a(window);a.fn.asynchImageLoader=a.fn.jail=function(d){d=a.extend({timeout:10,effect:false,speed:400,selector:null,offset:0,event:"load+scroll",callback:jQuery.noop,callbackAfterEachImage:jQuery.noop,placeholder:false,ignoreHiddenImages:false},d);var c=this;a.jail.initialStack=this;this.data("triggerEl",(d.selector)?a(d.selector):b);if(d.placeholder!==false){c.each(function(){a(this).attr("src",d.placeholder);});}if(/^load/.test(d.event)){a.asynchImageLoader.later.call(this,d);}else{a.asynchImageLoader.onEvent.call(this,d,c);}return this;};a.asynchImageLoader=a.jail={_purgeStack:function(c){var d=0;while(true){if(d===c.length){break;}else{if(c[d].getAttribute("data-href")){d++;}else{c.splice(d,1);}}}},_loadOnEvent:function(g){var f=a(this),d=g.data.options,c=g.data.images;a.asynchImageLoader._loadImageIfVisible(d,f);f.unbind(d.event,a.asynchImageLoader._loadOnEvent);a.asynchImageLoader._purgeStack(c);if(!!d.callback){a.asynchImageLoader._purgeStack(a.jail.initialStack);a.asynchImageLoader._launchCallback(a.jail.initialStack,d);}},_bufferedEventListener:function(g){var c=g.data.images,d=g.data.options,f=c.data("triggerEl");clearTimeout(c.data("poller"));c.data("poller",setTimeout(function(){c.each(function e(){a.asynchImageLoader._loadImageIfVisible(d,this,f);});a.asynchImageLoader._purgeStack(c);if(!!d.callback){a.asynchImageLoader._purgeStack(a.jail.initialStack);a.asynchImageLoader._launchCallback(a.jail.initialStack,d);}},d.timeout));},onEvent:function(d,c){c=c||this;if(d.event==="scroll"||d.selector){var e=c.data("triggerEl");if(c.length>0){e.bind(d.event,{images:c,options:d},a.asynchImageLoader._bufferedEventListener);if(d.event==="scroll"||!d.selector){b.resize({images:c,options:d},a.asynchImageLoader._bufferedEventListener);}return;}else{if(!!e){e.unbind(d.event,a.asynchImageLoader._bufferedEventListener);}}}else{c.bind(d.event,{options:d,images:c},a.asynchImageLoader._loadOnEvent);}},later:function(d){var c=this;if(d.event==="load"){c.each(function(){a.asynchImageLoader._loadImageIfVisible(d,this,c.data("triggerEl"));});}a.asynchImageLoader._purgeStack(c);a.asynchImageLoader._launchCallback(c,d);setTimeout(function(){if(d.event==="load"){c.each(function(){a.asynchImageLoader._loadImage(d,a(this));});}else{c.each(function(){a.asynchImageLoader._loadImageIfVisible(d,this,c.data("triggerEl"));});}a.asynchImageLoader._purgeStack(c);a.asynchImageLoader._launchCallback(c,d);if(d.event==="load+scroll"){d.event="scroll";a.asynchImageLoader.onEvent(d,c);}},d.timeout);},_launchCallback:function(c,d){if(c.length===0&&!a.jail.isCallback){d.callback.call(this,d);a.jail.isCallback=true;}},_loadImageIfVisible:function(e,h,g){var f=a(h),d=(/scroll/i.test(e.event))?g:b,c=true;if(e.ignoreHiddenImages){c=a.jail._isVisibleInOverflownContainer(f,e)&&f.is(":visible");}if(c&&a.asynchImageLoader._isInTheScreen(d,f,e.offset)){a.asynchImageLoader._loadImage(e,f);}},_isInTheScreen:function(j,c,h){var f=j[0]===window,n=(f?{top:0,left:0}:j.offset()),g=n.top+(f?j.scrollTop():0),i=n.left+(f?j.scrollLeft():0),e=i+j.width(),k=g+j.height(),m=c.offset(),l=c.width(),d=c.height();return(g-h)<=(m.top+d)&&(k+h)>=m.top&&(i-h)<=(m.left+l)&&(e+h)>=m.left;},_loadImage:function(c,d){d.hide();d.attr("src",d.attr("data-href"));d.removeAttr("data-href");if(c.effect){if(c.speed){d[c.effect](c.speed);}else{d[c.effect]();}}else{d.show();}c.callbackAfterEachImage.call(this,d,c);},_isVisibleInOverflownContainer:function(e,d){var f=e.parent(),c=true;while(f.get(0).tagName!=="BODY"){if(f.css("overflow")==="hidden"){if(!a.jail._isInTheScreen(f,e,d.offset)){c=false;break;}}if(f.css("visibility")==="hidden"||e.css("visibility")==="hidden"){c=false;break;}f=f.parent();}return c;}};}(jQuery));
|
10 |
/* bjll.js by Bjørn Johansen (@bjornjohansen) */
|
11 |
+
(function($){$(document).ready(function(){$('img.lazy').removeClass('lazy-hidden').jail(BJLL.options);});})(jQuery);
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: images, lazy loading, jquery, javascript, optimize, performance, bandwidth
|
|
5 |
Author URI: http://twitter.com/bjornjohansen
|
6 |
Requires at least: 3.2
|
7 |
Tested up to: 3.3
|
8 |
-
Stable tag: 0.2.
|
9 |
|
10 |
Lazy image loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users.
|
11 |
|
@@ -46,6 +46,10 @@ Check your HTML source or see the magic at work in FireBug or similar.
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
|
|
49 |
= Version 0.2.1 =
|
50 |
* Added options: Timeout, effect, speed, event, offset, ignoreHiddenImages
|
51 |
* Combining the two JS files for faster loading
|
@@ -62,6 +66,9 @@ Check your HTML source or see the magic at work in FireBug or similar.
|
|
62 |
|
63 |
== Upgrade Notice ==
|
64 |
|
|
|
|
|
|
|
65 |
= 0.2.1 =
|
66 |
More options and faster loading.
|
67 |
|
5 |
Author URI: http://twitter.com/bjornjohansen
|
6 |
Requires at least: 3.2
|
7 |
Tested up to: 3.3
|
8 |
+
Stable tag: 0.2.2
|
9 |
|
10 |
Lazy image loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users.
|
11 |
|
46 |
|
47 |
== Changelog ==
|
48 |
|
49 |
+
= Version 0.2.2 =
|
50 |
+
* Added CSS. No longer need for hiding .no-js .lazy
|
51 |
+
* Added options whether to include JS and CSS or not
|
52 |
+
|
53 |
= Version 0.2.1 =
|
54 |
* Added options: Timeout, effect, speed, event, offset, ignoreHiddenImages
|
55 |
* Combining the two JS files for faster loading
|
66 |
|
67 |
== Upgrade Notice ==
|
68 |
|
69 |
+
= 0.2.2 =
|
70 |
+
More options and improved non-JS display.
|
71 |
+
|
72 |
= 0.2.1 =
|
73 |
More options and faster loading.
|
74 |
|