Version Description
New JAIL version.
Download this release
Release Info
Developer | bjornjohansen |
Plugin | BJ Lazy Load |
Version | 0.4.0 |
Comparing to | |
See all releases |
Code changes from version 0.3.3 to 0.4.0
- bj-lazy-load.php +5 -5
- js/bjll.min.js +17 -6
- js/jail.min.js +17 -6
- readme.txt +8 -2
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.
|
7 |
Author: Bjørn Johansen
|
8 |
Author URI: http://twitter.com/bjornjohansen
|
9 |
License: GPL2
|
@@ -28,7 +28,7 @@ License: GPL2
|
|
28 |
|
29 |
class BJLL {
|
30 |
|
31 |
-
const version = '0.
|
32 |
private $_placeholder_url;
|
33 |
|
34 |
private static $_instance;
|
@@ -207,7 +207,7 @@ var BJLL = {
|
|
207 |
|
208 |
$class .= ' lazy lazy-hidden';
|
209 |
|
210 |
-
$img->setAttribute( 'data-
|
211 |
$img->setAttribute( 'src' , $this->_placeholder_url );
|
212 |
$img->setAttribute( 'class' , trim( $class ) );
|
213 |
|
@@ -226,8 +226,8 @@ var BJLL = {
|
|
226 |
$orig_html = $html;
|
227 |
|
228 |
/**/
|
229 |
-
// replace the src and add the data-
|
230 |
-
$html = preg_replace( '/<img(.*?)src=/i', '<img$1src="' . $this->_placeholder_url . '" data-
|
231 |
|
232 |
// add the lazy class to the img element
|
233 |
if ( preg_match( '/class="/i', $html ) ) {
|
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.4.0
|
7 |
Author: Bjørn Johansen
|
8 |
Author URI: http://twitter.com/bjornjohansen
|
9 |
License: GPL2
|
28 |
|
29 |
class BJLL {
|
30 |
|
31 |
+
const version = '0.4.0';
|
32 |
private $_placeholder_url;
|
33 |
|
34 |
private static $_instance;
|
207 |
|
208 |
$class .= ' lazy lazy-hidden';
|
209 |
|
210 |
+
$img->setAttribute( 'data-src' , $src );
|
211 |
$img->setAttribute( 'src' , $this->_placeholder_url );
|
212 |
$img->setAttribute( 'class' , trim( $class ) );
|
213 |
|
226 |
$orig_html = $html;
|
227 |
|
228 |
/**/
|
229 |
+
// replace the src and add the data-src attribute
|
230 |
+
$html = preg_replace( '/<img(.*?)src=/i', '<img$1src="' . $this->_placeholder_url . '" data-src=', $html );
|
231 |
|
232 |
// add the lazy class to the img element
|
233 |
if ( preg_match( '/class="/i', $html ) ) {
|
js/bjll.min.js
CHANGED
@@ -1,11 +1,22 @@
|
|
1 |
/*
|
2 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
*
|
4 |
-
* Developed by
|
5 |
-
* Sebastiano Armeli-Battana (@sebarmeli) - http://www.sebastianoarmelibattana.com
|
6 |
-
* Dual licensed under the MIT or GPL Version 3 licenses.
|
7 |
-
* @version 0.9.7
|
8 |
*/
|
9 |
-
|
10 |
/* bjll.js by Bjørn Johansen (@bjornjohansen) */
|
11 |
(function($){$(document).ready(function(){$('img.lazy').removeClass('lazy-hidden').jail(BJLL.options);});})(jQuery);
|
1 |
/*
|
2 |
+
* JAIL: jQuery Asynchronous Image Loader
|
3 |
+
*
|
4 |
+
* Copyright (c) 2011 Sebastiano Armeli-Battana (http://www.sebastianoarmelibattana.com)
|
5 |
+
*
|
6 |
+
* By Sebastiano Armeli-Battana (@sebarmeli) - http://www.sebastianoarmelibattana.com
|
7 |
+
* Licensed under the MIT license.
|
8 |
+
* https://github.com/sebarmeli/JAIL/blob/master/MIT-LICENSE.txt
|
9 |
+
*
|
10 |
+
* Tested with jQuery 1.3.2+ on FF 2+, Opera 10+, Safari 4+, Chrome 8+ on Win/Mac/Linux and IE 6/7/8 on Win.
|
11 |
+
*
|
12 |
+
* Contributor : Derek Lindahl - dlindahl
|
13 |
+
*
|
14 |
+
* @link http://github.com/sebarmeli/JAIL
|
15 |
+
* @author Sebastiano Armeli-Battana
|
16 |
+
* @date 30/12/2011
|
17 |
+
* @version 0.9.9
|
18 |
*
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
+
(function(a,c){var b=c(jQuery),d=typeof define==="function"&&define.amd;if(d){define("jail",["jquery"],b);}else{(this.jQuery||this.$||this)[a]=b;}}("jail",function(f){var b=f(window),d={timeout:1,effect:false,speed:400,triggerElement:null,offset:0,event:"load",callback:null,callbackAfterEachImage:null,placeholder:false,loadHiddenImages:false},k=[],g=false;f.jail=function(o,n){var o=o||{},n=f.extend({},d,n);f.jail.prototype.init(o,n);if(/^(load|scroll)/.test(n.event)){f.jail.prototype.later.call(o,n);}else{f.jail.prototype.onEvent.call(o,n);}};f.jail.prototype.init=function(o,n){o.data("triggerEl",(n.triggerElement)?f(n.triggerElement):b);if(!!n.placeholder){o.each(function(){f(this).attr("src",n.placeholder);});}};f.jail.prototype.onEvent=function(o){var n=this;if(!!o.triggerElement){i(o,n);}else{n.bind(o.event,{options:o,images:n},function(s){var r=f(this),q=s.data.options,p=s.data.images;k=f.extend({},p);a(q,r);f(s.currentTarget).unbind(s.type);});}};f.jail.prototype.later=function(o){var n=this;setTimeout(function(){k=f.extend({},n);n.each(function(){c(o,this,n);});o.event="scroll";i(o,n);},o.timeout);};function i(o,n){if(!!n){var p=n.data("triggerEl");}if(!!p&&typeof p.bind==="function"){p.bind(o.event,{options:o,images:n},m);b.resize({options:o,images:n},m);}}function j(n){var o=0;if(n.length>0){while(true){if(o===n.length){break;}else{if(n[o].getAttribute("data-src")){o++;}else{n.splice(o,1);}}}}}function m(p){var n=p.data.images,o=p.data.options;n.data("poller",setTimeout(function(){k=f.extend({},n);j(k);f(k).each(function(){if(this===window){return;}c(o,this,k);});if(l(k)){f(p.currentTarget).unbind(p.type);return;}else{if(o.event!=="scroll"){var q=(/scroll/i.test(o.event))?n.data("triggerEl"):b;o.event="scroll";n.data("triggerEl",q);i(o,f(k));}}},o.timeout));}function l(n){var o=true;f(n).each(function(){if(!!f(this).attr("data-src")){o=false;}});return o;}function c(q,s,o){var r=f(s),p=(/scroll/i.test(q.event))?o.data("triggerEl"):b,n=true;if(!q.loadHiddenImages){n=h(r,p,q)&&r.is(":visible");}if(n&&e(p,r,q.offset)){a(q,r);}}function e(u,n,s){var q=u[0]===window,y=(q?{top:0,left:0}:u.offset()),r=y.top+(q?u.scrollTop():0),t=y.left+(q?u.scrollLeft():0),p=t+u.width(),v=r+u.height(),x=n.offset(),w=n.width(),o=n.height();return(r-s)<=(x.top+o)&&(v+s)>=x.top&&(t-s)<=(x.left+w)&&(p+s)>=x.left;}function a(n,o){o.hide();o.attr("src",o.attr("data-src"));o.removeAttr("data-src");if(n.effect){if(n.speed){o[n.effect](n.speed);}else{o[n.effect]();}o.css("opacity",1);o.show();}else{o.show();}j(k);if(!!n.callbackAfterEachImage){n.callbackAfterEachImage.call(this,o,n);}if(l(k)&&!!n.callback&&!g){n.callback.call(f.jail,n);g=true;}}function h(q,o,p){var r=q.parent(),n=true;while(r.get(0).nodeName.toUpperCase()!=="BODY"){if(r.css("overflow")==="hidden"){if(!e(r,q,p.offset)){n=false;break;}}else{if(r.css("overflow")==="scroll"){if(!e(r,q,p.offset)){n=false;f(k).data("triggerEl",r);p.event="scroll";i(p,f(k));break;}}}if(r.css("visibility")==="hidden"||q.css("visibility")==="hidden"){n=false;break;}if(o!==b&&r===o){break;}r=r.parent();}return n;}f.fn.jail=function(n){new f.jail(this,n);k=[];return this;};return f.jail;}));
|
21 |
/* bjll.js by Bjørn Johansen (@bjornjohansen) */
|
22 |
(function($){$(document).ready(function(){$('img.lazy').removeClass('lazy-hidden').jail(BJLL.options);});})(jQuery);
|
js/jail.min.js
CHANGED
@@ -1,9 +1,20 @@
|
|
1 |
/*
|
2 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
*
|
4 |
-
* Developed by
|
5 |
-
* Sebastiano Armeli-Battana (@sebarmeli) - http://www.sebastianoarmelibattana.com
|
6 |
-
* Dual licensed under the MIT or GPL Version 3 licenses.
|
7 |
-
* @version 0.9.7
|
8 |
*/
|
9 |
-
|
1 |
/*
|
2 |
+
* JAIL: jQuery Asynchronous Image Loader
|
3 |
+
*
|
4 |
+
* Copyright (c) 2011 Sebastiano Armeli-Battana (http://www.sebastianoarmelibattana.com)
|
5 |
+
*
|
6 |
+
* By Sebastiano Armeli-Battana (@sebarmeli) - http://www.sebastianoarmelibattana.com
|
7 |
+
* Licensed under the MIT license.
|
8 |
+
* https://github.com/sebarmeli/JAIL/blob/master/MIT-LICENSE.txt
|
9 |
+
*
|
10 |
+
* Tested with jQuery 1.3.2+ on FF 2+, Opera 10+, Safari 4+, Chrome 8+ on Win/Mac/Linux and IE 6/7/8 on Win.
|
11 |
+
*
|
12 |
+
* Contributor : Derek Lindahl - dlindahl
|
13 |
+
*
|
14 |
+
* @link http://github.com/sebarmeli/JAIL
|
15 |
+
* @author Sebastiano Armeli-Battana
|
16 |
+
* @date 30/12/2011
|
17 |
+
* @version 0.9.9
|
18 |
*
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
+
(function(a,c){var b=c(jQuery),d=typeof define==="function"&&define.amd;if(d){define("jail",["jquery"],b);}else{(this.jQuery||this.$||this)[a]=b;}}("jail",function(f){var b=f(window),d={timeout:1,effect:false,speed:400,triggerElement:null,offset:0,event:"load",callback:null,callbackAfterEachImage:null,placeholder:false,loadHiddenImages:false},k=[],g=false;f.jail=function(o,n){var o=o||{},n=f.extend({},d,n);f.jail.prototype.init(o,n);if(/^(load|scroll)/.test(n.event)){f.jail.prototype.later.call(o,n);}else{f.jail.prototype.onEvent.call(o,n);}};f.jail.prototype.init=function(o,n){o.data("triggerEl",(n.triggerElement)?f(n.triggerElement):b);if(!!n.placeholder){o.each(function(){f(this).attr("src",n.placeholder);});}};f.jail.prototype.onEvent=function(o){var n=this;if(!!o.triggerElement){i(o,n);}else{n.bind(o.event,{options:o,images:n},function(s){var r=f(this),q=s.data.options,p=s.data.images;k=f.extend({},p);a(q,r);f(s.currentTarget).unbind(s.type);});}};f.jail.prototype.later=function(o){var n=this;setTimeout(function(){k=f.extend({},n);n.each(function(){c(o,this,n);});o.event="scroll";i(o,n);},o.timeout);};function i(o,n){if(!!n){var p=n.data("triggerEl");}if(!!p&&typeof p.bind==="function"){p.bind(o.event,{options:o,images:n},m);b.resize({options:o,images:n},m);}}function j(n){var o=0;if(n.length>0){while(true){if(o===n.length){break;}else{if(n[o].getAttribute("data-src")){o++;}else{n.splice(o,1);}}}}}function m(p){var n=p.data.images,o=p.data.options;n.data("poller",setTimeout(function(){k=f.extend({},n);j(k);f(k).each(function(){if(this===window){return;}c(o,this,k);});if(l(k)){f(p.currentTarget).unbind(p.type);return;}else{if(o.event!=="scroll"){var q=(/scroll/i.test(o.event))?n.data("triggerEl"):b;o.event="scroll";n.data("triggerEl",q);i(o,f(k));}}},o.timeout));}function l(n){var o=true;f(n).each(function(){if(!!f(this).attr("data-src")){o=false;}});return o;}function c(q,s,o){var r=f(s),p=(/scroll/i.test(q.event))?o.data("triggerEl"):b,n=true;if(!q.loadHiddenImages){n=h(r,p,q)&&r.is(":visible");}if(n&&e(p,r,q.offset)){a(q,r);}}function e(u,n,s){var q=u[0]===window,y=(q?{top:0,left:0}:u.offset()),r=y.top+(q?u.scrollTop():0),t=y.left+(q?u.scrollLeft():0),p=t+u.width(),v=r+u.height(),x=n.offset(),w=n.width(),o=n.height();return(r-s)<=(x.top+o)&&(v+s)>=x.top&&(t-s)<=(x.left+w)&&(p+s)>=x.left;}function a(n,o){o.hide();o.attr("src",o.attr("data-src"));o.removeAttr("data-src");if(n.effect){if(n.speed){o[n.effect](n.speed);}else{o[n.effect]();}o.css("opacity",1);o.show();}else{o.show();}j(k);if(!!n.callbackAfterEachImage){n.callbackAfterEachImage.call(this,o,n);}if(l(k)&&!!n.callback&&!g){n.callback.call(f.jail,n);g=true;}}function h(q,o,p){var r=q.parent(),n=true;while(r.get(0).nodeName.toUpperCase()!=="BODY"){if(r.css("overflow")==="hidden"){if(!e(r,q,p.offset)){n=false;break;}}else{if(r.css("overflow")==="scroll"){if(!e(r,q,p.offset)){n=false;f(k).data("triggerEl",r);p.event="scroll";i(p,f(k));break;}}}if(r.css("visibility")==="hidden"||q.css("visibility")==="hidden"){n=false;break;}if(o!==b&&r===o){break;}r=r.parent();}return n;}f.fn.jail=function(n){new f.jail(this,n);k=[];return this;};return f.jail;}));
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: images, lazy loading, jquery, javascript, optimize, performance, bandwidth
|
5 |
Author URI: http://twitter.com/bjornjohansen
|
6 |
Requires at least: 3.1
|
7 |
-
Tested up to: 3.3.
|
8 |
-
Stable tag: 0.
|
9 |
|
10 |
Lazy image loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users.
|
11 |
|
@@ -58,6 +58,9 @@ Check your HTML source or see the magic at work in Web Inspector, FireBug or sim
|
|
58 |
|
59 |
== Changelog ==
|
60 |
|
|
|
|
|
|
|
61 |
= Version 0.3.3 =
|
62 |
* Replaced an anonymous function call causing error in PHP < 5.3
|
63 |
|
@@ -105,6 +108,9 @@ Check your HTML source or see the magic at work in Web Inspector, FireBug or sim
|
|
105 |
|
106 |
== Upgrade Notice ==
|
107 |
|
|
|
|
|
|
|
108 |
= 0.3.2 =
|
109 |
Lazy load any image in your theme. Load in head.
|
110 |
|
4 |
Tags: images, lazy loading, jquery, javascript, optimize, performance, bandwidth
|
5 |
Author URI: http://twitter.com/bjornjohansen
|
6 |
Requires at least: 3.1
|
7 |
+
Tested up to: 3.3.2
|
8 |
+
Stable tag: 0.4.0
|
9 |
|
10 |
Lazy image loading makes your site load faster and saves bandwidth. Uses jQuery and degrades gracefully for non-js users.
|
11 |
|
58 |
|
59 |
== Changelog ==
|
60 |
|
61 |
+
= Version 0.4.0 =
|
62 |
+
* Upgraded JAIL to version 0.9.9, fixing some bugs. Note: data-href is now renamed data-src.
|
63 |
+
|
64 |
= Version 0.3.3 =
|
65 |
* Replaced an anonymous function call causing error in PHP < 5.3
|
66 |
|
108 |
|
109 |
== Upgrade Notice ==
|
110 |
|
111 |
+
= 0.4.0 =
|
112 |
+
New JAIL version.
|
113 |
+
|
114 |
= 0.3.2 =
|
115 |
Lazy load any image in your theme. Load in head.
|
116 |
|