Plugin Directory

Changeset 2961962


Ignore:
Timestamp:
09/02/2023 01:00:56 PM (3 years ago)
Author:
easywpstuff
Message:

update

Location:
easy-optimizer
Files:
12 added
2 edited

Legend:

Unmodified
Added
Removed
  • easy-optimizer/trunk/easy-optimizer.php

    r2961303 r2961962  
    44Plugin URI:
    55Description: A plugin to preload pages and lazy-load images to improve FCP, LCP (Largest Contentful Paint), and overall performance.
    6 Version: 1.0.7
     6Version: 1.0.8
    77Author: Uzair
    88Author URI: https://easywpstuff.com
     
    207207        foreach ( $html->find( 'img' ) as $img ) {
    208208            // Check if the img tag has the class "lazyload" or contains base64 src or is inside the wpadminbar
    209             $has_lazyload_class = $img->hasClass('lazyload') || $img->hasClass('rplg-blazy');
     209            $has_lazyload_class = $img->hasClass('lazyload') || $img->hasClass('rplg-blazy') || $img->hasClass('rs-lazyload');
    210210            $has_base64_src = ( strpos( $img->getAttribute('src'), 'base64' ) !== false ) ||( strpos( $img->getAttribute('src'), 'data:image' ) !== false );
    211211            $is_inside_wpadminbar = eop_is_inside_wpadminbar( $img );
     
    221221                    // Check if the img tag has srcset
    222222                    $has_srcset = $img->hasAttribute( 'srcset' );
     223                    $imgwidth  = $img->getAttribute( 'width' );
     224                    $imgheight = $img->getAttribute( 'height' );
     225                    if (empty($imgwidth) && empty($imgheight)) {
     226                        $src = $img->getAttribute('src');
     227                        list($width, $height) = getimagesize($src);
     228                        if ($width && $height) {
     229                            $img->setAttribute('width', $width);
     230                            $img->setAttribute('height', $height);
     231                        }
     232                    }
     233                    if (!empty($width) && !empty($height)) {
     234                    $placeholder = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 $width $height'%3E%3C/svg%3E";
     235                    } elseif (!empty($imgwidth) && !empty($imgheight))  {
     236                        $placeholder = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 $imgwidth $imgheight'%3E%3C/svg%3E"; 
     237                    } else {
     238                        $placeholder = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
     239                    }
    223240
    224241                    // Replace srcset with data-srcset if it exists
     
    227244                        $img->removeAttribute( 'srcset' );
    228245                        $img->setAttribute( 'data-src', $img->getAttribute( 'src' ) );
    229                         $img->setAttribute( 'src', "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 1'%3E%3C/svg%3E" );
     246                        $img->setAttribute( 'src', $placeholder );
    230247                    } else {
    231248                        // Add data-src attribute if no srcset exists
    232249                        $img->setAttribute( 'data-src', $img->getAttribute( 'src' ) );
    233                         $img->setAttribute( 'src', "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 1'%3E%3C/svg%3E" );
     250                        $img->setAttribute( 'src', $placeholder);
    234251                    }
    235252                    $picture = $img->parent();
  • easy-optimizer/trunk/readme.txt

    r2961303 r2961962  
    33Tags: lazyload, elementor, speed, avif, lazy load, core web vitals
    44Requires at least: 5.0
    5 Tested up to: 6.3
     5Tested up to: 6.3.1
    66Requires PHP: 5.6
    7 Stable tag: 1.0.7
     7Stable tag: 1.0.8
    88License: GNU General Public License v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2222
    2323The plugin has an option to convert images to Avif or webp autmatically via shortpixel cdn when the browser is supported. You need to signup [ShortPixel Here](https://easywpstuff.com/shortpixel) then just associate your domain. That's it! You're all set to enjoy up to 500MB of free usage per month.
    24 #### 2. Lazy Load Images
     24
     25#### 2. Image elements do not have explicit width and height
     26
     27The plugin automatically adds width and height to the images when lazyloading is enabled
     28
     29
     30#### 3. Lazy Load Images
    2531
    2632Lazy loading images is a technique that significantly improves your website's loading times. Instead of loading all images at once when a user visits a page, the plugin ensures that images are loaded only when they come into the user's viewport. This results in faster initial page loading and reduces unnecessary data consumption, leading to improved FCP and LCP scores.
    2733
    28 #### 2. Lazy Load Iframes and HTML video
     34#### 4. Lazy Load Iframes and HTML video
    2935
    3036The Easy Optimizer plugin extends its lazy loading capabilities to iframes and autoplaying html5 videos.
    3137
    32 #### 3. Page Preloading
     38#### 5. Page Preloading
    3339
    3440Preloading pages is another essential feature of Easy Optimizer. By intelligently preloading linked pages in the background while users navigate your site, subsequent page loads become faster and smoother. Preloading reduces the perceived loading time, making your website feel more responsive and enjoyable for visitors.
Note: See TracChangeset for help on using the changeset viewer.