Plugin Directory

Changeset 3089755


Ignore:
Timestamp:
05/21/2024 02:09:02 AM (21 months ago)
Author:
beleaf
Message:

Release 1.6.1

Location:
lazy-embed
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • lazy-embed/trunk/lazy-embed.php

    r3066506 r3089755  
    77 * Plugin URI: https://bitbucket.org/beleaf-au/lazy-embed/
    88 * Description: Improves the performance and reduces the emissions of your website by only loading embeds (youtube, vimeo, etc) when they are clicked.
    9  * Version: 1.6.0
     9 * Version: 1.6.1
    1010 * Requires PHP: 7.1
    1111 * Requires at least: 6.2.0
     
    3434        {
    3535            if ($block['blockName'] === 'core/embed' || $block['blockName'] === 'core/video') {
     36                $tag = $block['blockName'] === 'core/embed'
     37                    ? 'iframe'
     38                    : 'video';
     39
     40                $processor = new \WP_HTML_Tag_Processor($html);
     41                $processor->next_tag($tag);
     42
    3643                if (!empty($block['attrs']['className']) && str_contains($block['attrs']['className'], self::IGNORE_STRING)) {
    37 
    38                     $tag = $block['blockName'] === 'core/embed'
    39                         ? 'iframe'
    40                         : 'video';
    41 
    42                     $processor = new \WP_HTML_Tag_Processor($html);
    43                     $processor->next_tag($tag);
    4444                    $processor->add_class(self::IGNORE_STRING);
    45 
     45                    return $processor->get_updated_html();
     46                }elseif($tag === 'iframe') {
     47                    $processor->set_attribute('loading', 'lazy');
    4648                    return $processor->get_updated_html();
    4749                }
     
    181183            $srcdoc .= '<a href="' . esc_url($iframeSrc) . '">';
    182184            $srcdoc .= "<span>$play</span>";
    183             $srcdoc .= '<img src="' . esc_url($imageSrc) . '">';
     185            $srcdoc .= '<img loading="lazy" src="' . esc_url($imageSrc) . '">';
    184186            $srcdoc .= '</a>';
    185187
     
    256258            // https://ourcodeworld.com/articles/read/1364/how-to-obtain-the-thumbnails-of-any-youtube-video
    257259            return !empty($id)
    258                 ? "https://img.youtube.com/vi/$id/hqdefault.jpg"
     260                ? "https://img.youtube.com/vi/$id/maxresdefault.jpg"
    259261                : '';
    260262        }
  • lazy-embed/trunk/readme.txt

    r3066506 r3089755  
    44Requires at least: 6.2.0
    55Tested up to: 6.4
    6 Stable tag: 1.6.0
     6Stable tag: 1.6.1
    77Requires PHP: 5.6
    88License: GPLv2 or later
     
    2727== Changelog ==
    2828
    29 = 1.6.0 =
     29= 1.6.1 =
     30Fix: Load high resolution thumbnail from youtube
     31Fix: Lazy load iframe and img tag placeholder
     32
     33= 1.6.0 - 08/04/2024 =
    3034Feat: Replace regular expressions with WP_HTML_Tag_Processor
    3135Fix: A missing src tag on an iframe resulted in a fatal error. This nolonger happens. Thanks Dan
Note: See TracChangeset for help on using the changeset viewer.