Changeset 1813516
- Timestamp:
- 02/01/2018 02:12:09 PM (8 years ago)
- Location:
- smart-image-loader/trunk
- Files:
-
- 4 edited
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
smart_image_loader.js (modified) (3 diffs)
-
smart_image_loader.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smart-image-loader/trunk/plugin.php
r1543509 r1813516 4 4 Plugin URI: https://wordpress.org/plugins/smart-image-loader 5 5 Description: Load images visible at page load ('above the fold') first for a fast page loading impression. Optional lazy loading for images 'below the fold'. 6 Version: 0. 4.86 Version: 0.5.0 7 7 Text Domain: smart-image-loader 8 8 Author: Bayer und Preuss -
smart-image-loader/trunk/readme.txt
r1581779 r1813516 1 1 === Smart Image Loader === 2 Contributors: 3 Donate link: 2 Contributors: Nils Poltoraczyk, Bayer und Preuss GmbH 4 3 Tags: performance, speed, lazy loading, image, above the fold 5 4 Requires at least: 3.8.3 6 Tested up to: 4. 7.27 Stable tag: 0. 4.85 Tested up to: 4.9.3 6 Stable tag: 0.5.0 8 7 License: GPLv2 or later 9 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 32 31 33 32 == Changelog == 33 34 = 0.5.0 = 35 * fixed minor bug that would try to write sizes attribute even when none are defined 34 36 35 37 = 0.4.8 = -
smart-image-loader/trunk/smart_image_loader.js
r1543509 r1813516 1 1 (function($) { 2 2 3 // Version: 0. 4.83 // Version: 0.5.0 4 4 5 5 "use strict"; … … 217 217 var 218 218 classId = $wrapping_image.attr('data-sil'), 219 $noscript = $noscripts.filter( '[data-sil="' + classId + '"]'); 219 $noscript = $noscripts.filter( '[data-sil="' + classId + '"]'), 220 sizes, 221 srcSet, 222 src; 220 223 221 224 … … 235 238 } 236 239 237 $wrapping_image.attr( 'sizes', "(max-width: "+window_width+"px) " + parseInt($wrapping_image.data("width") / window_width * 100) + "vw, " + $wrapping_image.attr( 'sizes' ) ); 238 $wrapping_image.attr( 'srcset', $noscript.attr('data-srcset') ); 239 $wrapping_image.attr( 'src', $noscript.attr('data-src') ); 240 sizes = '(max-width: '+window_width+'px) ' + parseInt($wrapping_image.data('width') / window_width * 100) + 'vw'; 241 if ( $wrapping_image.attr( 'sizes' ) ) 242 { 243 sizes += (", " + $wrapping_image.attr( 'sizes' )); 244 } 245 $wrapping_image.attr( 'sizes', sizes ); 246 247 srcSet = $noscript.attr('data-srcset'); 248 if ( srcSet ) { 249 $wrapping_image.attr( 'srcset', srcSet ); 250 } 251 252 src = $noscript.attr('data-src'); 253 if ( src ) { 254 $wrapping_image.attr( 'src', $noscript.attr('data-src') ); 255 } 240 256 241 257 $loading_images = $loading_images.add( $wrapping_image ); -
smart-image-loader/trunk/smart_image_loader.min.js
r1492699 r1813516 7 7 }else{if(this.nodeType&&this.nodeType==1){w=this;}}Y=D(w).attr("src");return Y==W.placeholder||Y==e;},F=function(d){return typeof d.width=="string"&&d.width.match(/^\d+$/)&&typeof d.height=="string"&&d.height.match(/^\d+$/); 8 8 },a=function(d){d=d||s||D("body").find("noscript").prev(W.selector);d.each(function(){var w=D(this);w.data({offsetTop:w.offset().top,offsetLeft:w.offset().left,width:w.width(),height:w.height(),visibility:N(this,"display")!="none"&&N(this,"visibility")!="hidden"&&N(this,"opacity")!="0"&&w.is(":visible")}); 9 });c=D(V).height();},J=function( Z,Y,d){R=D(Z);var w=R.attr("data-sil"),aa=o.filter('[data-sil="'+w+'"]');if(typeof Y=="function"){R.on("load",Y);}if(W.fade&&!d){R.data({opacity:R.css("opacity")}).css({opacity:"0"});10 R.on("load",function(){D(this).fadeTo(500,D(this).data("opacity"));});}R.attr("sizes","(max-width: "+u+"px) "+parseInt(R.data("width")/u*100)+"vw, "+R.attr("sizes"));11 R.attr("srcset",aa.attr("data-srcset"));R.attr("src",aa.attr("data-src"));A=A.add(R);requestAnimationFrame(function(){if(!F(Z)){a(s);G();}});if(W.cleanup){aa.parent("span").remove();12 } },G=function(d){var w=s.filter(I);if(w.length>0){w.each(function(Y,Z){s=s.map(function(){if(this!==Z){return this;}});J(Z,z,d);});}},p=function(){s.each(function(){var d=this;13 J(d,z);s=s.map(function(){if(this!==d){return this;}});});},z=function(w){var d,Y;v.trigger("sil_load",w.target);if(!F(w.target)){a(s);G();}w.target.removeAttribute("data-sil");14 d=s.filter(I);Y=s.not(d);A=A.map(function(){if(this!==w.target){return this;}});if(d.length+A.length===0){if(Y.length===0){i();}else{E();}}},E=function(){v.trigger("sil_load_visible");15 if(s.length===0){i();}else{if(!q){p();}}},i=function(){v.trigger("sil_load_all");},U=window.sil_refresh=function(){if(n===true){a(s);G();}},K=function(d){Q=d;16 },m=function(d){X=d;},l=function(){window.requestAnimationFrame(P);},k=function(){c=v.height();},h=function(){D(L).on("resize",m);D(L).on("load",k);v.on("scroll",K);17 v.ready(l);},b=function(){D(L).off("resize",m);v.off("scroll",K);},B=function(d){if(y()){C=v.scrollTop();j=v.scrollLeft();if(W.refresh_scroll){a(s);}G();18 x=Q;}if(S()){u=M().width;H=M().height;a(s);if(W.refresh_resize){a(s);}G();T=X;}if(!t){L.requestAnimationFrame(B);}else{b();}},P=function(){r=D("html, body");19 o=D("body").find("noscript[data-sil]");s=D(W.selector+"[data-sil]");u=M().width;H=M().height;e=V.location.protocol+"//"+V.location.host+"/";C=v.scrollTop();20 j=v.scrollLeft();c=v.height();A=D([]);t=s.length>0?false:true;a(s);G(true);B();n=true;};rf_poly();h();})(jQuery);function rf_poly(){var b=0;var c=["webkit","moz"];21 for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"];9 });c=D(V).height();},J=function(ab,aa,d){R=D(ab);var Z=R.attr("data-sil"),ac=o.filter('[data-sil="'+Z+'"]'),Y,w,ad;if(typeof aa=="function"){R.on("load",aa); 10 }if(W.fade&&!d){R.data({opacity:R.css("opacity")}).css({opacity:"0"});R.on("load",function(){D(this).fadeTo(500,D(this).data("opacity"));});}Y="(max-width: "+u+"px) "+parseInt(R.data("width")/u*100)+"vw"; 11 if(R.attr("sizes")){Y+=(", "+R.attr("sizes"));}R.attr("sizes",Y);w=ac.attr("data-srcset");if(w){R.attr("srcset",w);}ad=ac.attr("data-src");if(ad){R.attr("src",ac.attr("data-src")); 12 }A=A.add(R);requestAnimationFrame(function(){if(!F(ab)){a(s);G();}});if(W.cleanup){ac.parent("span").remove();}},G=function(d){var w=s.filter(I);if(w.length>0){w.each(function(Y,Z){s=s.map(function(){if(this!==Z){return this; 13 }});J(Z,z,d);});}},p=function(){s.each(function(){var d=this;J(d,z);s=s.map(function(){if(this!==d){return this;}});});},z=function(w){var d,Y;v.trigger("sil_load",w.target); 14 if(!F(w.target)){a(s);G();}w.target.removeAttribute("data-sil");d=s.filter(I);Y=s.not(d);A=A.map(function(){if(this!==w.target){return this;}});if(d.length+A.length===0){if(Y.length===0){i(); 15 }else{E();}}},E=function(){v.trigger("sil_load_visible");if(s.length===0){i();}else{if(!q){p();}}},i=function(){v.trigger("sil_load_all");},U=window.sil_refresh=function(){if(n===true){a(s); 16 G();}},K=function(d){Q=d;},m=function(d){X=d;},l=function(){window.requestAnimationFrame(P);},k=function(){c=v.height();},h=function(){D(L).on("resize",m); 17 D(L).on("load",k);v.on("scroll",K);v.ready(l);},b=function(){D(L).off("resize",m);v.off("scroll",K);},B=function(d){if(y()){C=v.scrollTop();j=v.scrollLeft(); 18 if(W.refresh_scroll){a(s);}G();x=Q;}if(S()){u=M().width;H=M().height;a(s);if(W.refresh_resize){a(s);}G();T=X;}if(!t){L.requestAnimationFrame(B);}else{b(); 19 }},P=function(){r=D("html, body");o=D("body").find("noscript[data-sil]");s=D(W.selector+"[data-sil]");u=M().width;H=M().height;e=V.location.protocol+"//"+V.location.host+"/"; 20 C=v.scrollTop();j=v.scrollLeft();c=v.height();A=D([]);t=s.length>0?false:true;a(s);G(true);B();n=true;};rf_poly();h();})(jQuery);function rf_poly(){var b=0; 21 var c=["webkit","moz"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]; 22 22 }if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f); 23 23 },f);b=d+f;return g;};}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d);};}}
Note: See TracChangeset
for help on using the changeset viewer.