Support » Plugin: Lazy Load » A couple other bugs impacting functionality

  • Resolved roam92

    (@roam92)


    In addition to my earlier post about JavaScript support, here are a couple other bugs in the Rocket Lazy Load plugin which impact basic functionality… I have also provided quick patches below to address these:

    1. The plugin promises to lazy load <iframe>s when turned on, but except for YouTube iframes, this didn’t seem to work for me… The reason is because of a slight coding issue in rocket-lazy-load.php where it’s reassigning the same variable without ever using the first result…

    Original code:

    $iframe_lazyload = str_replace( $iframe[2], ' data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . esc_url( $iframe[1] ) . '"' . $iframe[2], $iframe[0] );

    Replaced with:

    $iframe_lazyload = str_replace( $iframe[2], ' data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . esc_url( $iframe[1] ) . '"' . $iframe[2], $iframe_lazyload );

    2. As noted, the plugin does replace YouTube video iframes with a <div> plus an img for lazy loading… However, oddly, it doesn’t end up lazy loading its own replaced img!

    So I added the following (as well as “alt” tags)…

    Original code:

    <script>function lazyLoadThumb(e){var t='<img src="https://i.ytimg.com/vi/ID/$thumbnail_resolution.jpg">',a='<div class="play"></div>';

    Replaced with:

    <script>function lazyLoadThumb(e){var t='<img src="" data-lazy-src="https://i.ytimg.com/vi/ID/$thumbnail_resolution.jpg" alt="Play Video" title="Play Video">',a='<div class="play"></div>';

    Ideally, it would use the “placeholder” here for the original img, but the patch above did the trick for me.

    Again, I like this plugin a lot and will continue using it – just hope these fixes get integrated properly into the main plugin code base. Thanks again!

    • This topic was modified 2 years, 1 month ago by roam92.
    • This topic was modified 2 years, 1 month ago by roam92.
    • This topic was modified 2 years, 1 month ago by roam92.
    • This topic was modified 2 years, 1 month ago by roam92.
    • This topic was modified 2 years, 1 month ago by roam92.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP Media

    (@wp_media)

    Hi,

    Thank you for reporting these. They should be fixed since 2.0.

    Greetings,

    I just upgraded to 2.x, as it seems stable enough now. I’m running version Version 2.0.4 since this morning…

    It looks like #1 above was fixed – thanks! I appreciate it.

    However, #2 above has not been addressed. Nothing really changed there. So I had to patch the code again. Here’s the change now that I made in /rocket-lazy-load/vendor/wp-media/rocket-lazyload-common/src/Assets.php –

    Original code:

    ... var t='<img src=\"https://i.ytimg.com/vi/ID/{$args['resolution']}.jpg\">',a='<div class=\"play\"></div>'; ...

    Replaced with:

    ... var t='<img src=\"\" data-lazy-src=\"https://i.ytimg.com/vi/ID/{$args['resolution']}.jpg\" alt=\"Play Video\" title=\"Play Video\">',a='<div class=\"play\" alt=\"Play Video\" title=\"Play Video\"></div>'; ...

    Hope this can actually make it into the official plugin source!

    NB: You’d probably have to toggle it, based on the ‘LazyLoad Images’ on/off setting.

    In addition, I tweaked the CSS in that same file to center the youtube.png play button within the placeholder image:

    Original code:

    ... height:72px;width:72px;left:50%;top:50%; ...

    Replaced with:

    ... height:45px;width:64px;left:50.5%;top:54%; ...

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘A couple other bugs impacting functionality’ is closed to new replies.