Plugin Directory

Changeset 1813516


Ignore:
Timestamp:
02/01/2018 02:12:09 PM (8 years ago)
Author:
bypr.nils
Message:

fixed minor bug that would try to write sizes attribute even when none are defined

Location:
smart-image-loader/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • smart-image-loader/trunk/plugin.php

    r1543509 r1813516  
    44Plugin URI: https://wordpress.org/plugins/smart-image-loader
    55Description: 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.8
     6Version: 0.5.0
    77Text Domain: smart-image-loader
    88Author: Bayer und Preuss
  • smart-image-loader/trunk/readme.txt

    r1581779 r1813516  
    11=== Smart Image Loader ===
    2 Contributors:
    3 Donate link:
     2Contributors: Nils Poltoraczyk, Bayer und Preuss GmbH
    43Tags: performance, speed, lazy loading, image, above the fold
    54Requires at least: 3.8.3
    6 Tested up to: 4.7.2
    7 Stable tag: 0.4.8
     5Tested up to: 4.9.3
     6Stable tag: 0.5.0
    87License: GPLv2 or later
    98License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3231
    3332== Changelog ==
     33
     34= 0.5.0 =
     35* fixed minor bug that would try to write sizes attribute even when none are defined
    3436
    3537= 0.4.8 =
  • smart-image-loader/trunk/smart_image_loader.js

    r1543509 r1813516  
    11(function($) {
    22
    3     // Version: 0.4.8
     3    // Version: 0.5.0
    44
    55    "use strict";
     
    217217        var
    218218        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;
    220223
    221224
     
    235238        }
    236239
    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        }
    240256
    241257        $loading_images = $loading_images.add( $wrapping_image );
  • smart-image-loader/trunk/smart_image_loader.min.js

    r1492699 r1813516  
    77}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+$/);
    88},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";
     11if(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);
     14if(!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);
     16G();}},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);
     17D(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();
     18if(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+"/";
     20C=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;
     21var 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"];
    2222}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);
    2323},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.