WordPress.org

Plugin Directory

Changeset 1438670


Ignore:
Timestamp:
06/17/16 17:45:27 (20 months ago)
Author:
xiaoxu125634
Message:

3.4

  • 2016-06-15
  • upgrade: fix compatibility with imgs with srcset attribute, feature start from WordPress 4.4.
  • upgrade: optimize lazyload process, use $(document).trigger("lazyimgs") to update cached lazyimgs.
Location:
images-lazyload-and-slideshow/trunk
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • images-lazyload-and-slideshow/trunk/front.php

    r1194190 r1438670  
    88if ($config["lazyload"]) { 
    99    $lazyload_applyed = TRUE; 
     10 
     11    add_action('template_redirect', 'lazyload_slideshow_enqueue_scripts'); 
     12    function lazyload_slideshow_enqueue_scripts() { 
     13        $skip_lazyload = apply_filters('lazyload_slideshow_skip_lazyload', false); 
     14 
     15        // don't lazyload for feeds, previews 
     16        if( $skip_lazyload || is_feed() || is_preview() ) { 
     17            return; 
     18        } 
     19 
     20        wp_enqueue_style('responsively-lazy', Lazyload_Slideshow_Plugin_Url.'responsively-lazy/1.2.1/responsivelyLazy.min.css'); 
     21        wp_enqueue_script('responsively-lazy', Lazyload_Slideshow_Plugin_Url.'responsively-lazy/1.2.1/responsivelyLazy.min.js'); 
     22    } 
    1023 
    1124    if ($config["lazyload_all"]) { 
     
    90103        } 
    91104 
     105        /* 
    92106        $regexp = "/<img([^<>]*)src=['\"]([^<>'\"]*)['\"]([^<>]*)>/i"; 
    93107        $replace = '<img$1src="'.$alt_image_src.'" file="$2"$3><noscript>'.$matches[0].'</noscript>'; 
     
    97111            $lazyimg_str 
    98112        ); 
     113        */ 
     114        if (stripos($lazyimg_str,'srcset=')) { 
     115            if (!stripos($lazyimg_str,'data-srcset=')) { 
     116                $regexp = "/<img([^<>]*)srcset=['\"]([^<>'\"]*)['\"]([^<>]*)>/i"; 
     117                $replace = '<img$1srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-srcset="$2"$3>'; 
     118                $lazyimg_str = preg_replace( 
     119                    $regexp, 
     120                    $replace, 
     121                    $lazyimg_str 
     122                ); 
     123                $lazyimg_str = str_ireplace('ls_lazyimg','responsively-lazy',$lazyimg_str); 
     124 
     125                /*global $responsively_lazy_loaded; 
     126                if (!isset($responsively_lazy_loaded)) $responsively_lazy_loaded = 0; 
     127                if (!$responsively_lazy_loaded) { 
     128                    wp_enqueue_style('responsively-lazy',Lazyload_Slideshow_Plugin_Url.'responsively-lazy/1.2.1/responsivelyLazy.min.css'); 
     129                    wp_enqueue_script('responsively-lazy',Lazyload_Slideshow_Plugin_Url.'responsively-lazy/1.2.1/responsivelyLazy.min.js'); 
     130                    $responsively_lazy_loaded = 1; 
     131                }*/ // 没用 
     132            } 
     133            $lazyimg_str = str_ireplace('ls_lazyimg','',$lazyimg_str); 
     134        } else { 
     135            $regexp = "/<img([^<>]*)src=['\"]([^<>'\"]*)['\"]([^<>]*)>/i"; 
     136            $replace = '<img$1src="'.$alt_image_src.'" file="$2"$3><noscript>'.$matches[0].'</noscript>'; 
     137            $lazyimg_str = preg_replace( 
     138                $regexp, 
     139                $replace, 
     140                $lazyimg_str 
     141            ); 
     142        } 
    99143 
    100144        return $lazyimg_str; 
     
    136180 
    137181jQuery(function($) { 
    138 window._lazyimgs = $("img.ls_lazyimg"); 
     182$(document).bind("lazyimgs",function(){ 
     183    if (!window._lazyimgs) { 
     184        window._lazyimgs = $("img.ls_lazyimg"); 
     185    } else { 
     186        var _lazyimgs_new = $("img.ls_lazyimg:not([lazyloadindexed=1])"); 
     187        if (_lazyimgs_new.length > 0) { 
     188            //window._lazyimgs.add(_lazyimgs_new); // NG 
     189            window._lazyimgs = $(window._lazyimgs.toArray().concat(_lazyimgs_new.toArray())); 
     190        } 
     191    } 
     192    window._lazyimgs.attr("lazyloadindexed", 1); 
     193}); 
     194$(document).trigger("lazyimgs"); 
    139195if (_lazyimgs.length == 0) { 
    140196    return; 
  • images-lazyload-and-slideshow/trunk/lazyload-slideshow.php

    r1194190 r1438670  
    66Author: Bruno Xu 
    77Author URI: http://www.brunoxu.com/ 
    8 Version: 3.3 
     8Version: 3.4 
    99License: GNU General Public License v2 or later 
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1111*/ 
    1212 
    13 define('Lazyload_Slideshow_Version', '3.3'); 
     13define('Lazyload_Slideshow_Version', '3.4'); 
    1414define('Lazyload_Slideshow_Name', 'Images Lazyload and Slideshow'); 
    1515define('Lazyload_Slideshow_Config_Effect', "lazyload_slideshow_effects"); 
  • images-lazyload-and-slideshow/trunk/readme.txt

    r1194190 r1438670  
    44Tags: lazy load, lazyload, images lazy load, images, lazy loading, lightbox, images gallery, images slideshow, gallery slideshow, custom html, fancybox, prettyPhoto, slimbox2 
    55Requires at least: 3.0 
    6 Tested up to: 4.2.2 
     6Tested up to: 4.5.2 
    77Stable tag: trunk 
    88 
     
    5252 
    5353== Changelog == 
     54 
     55= 3.4 = 
     56* 2016-06-15 
     57* upgrade: fix compatibility with imgs with srcset attribute, feature start from WordPress 4.4. 
     58* upgrade: optimize lazyload process, use `$(document).trigger("lazyimgs")` to update cached lazyimgs. 
    5459 
    5560= 3.3 = 
Note: See TracChangeset for help on using the changeset viewer.