• Working on adding manual support for my SEO theme which uses images outside the standard media upload functions for thumbnails (created on the fly, sort of) on archives and widgets: Rocket Lazyload doesn’t add the lazyload code to the image output.

    Found your documentation on this at https://docs.wp-rocket.me/article/130-manually-apply-lazyload-to-an-image and it’s out of date and incomplete.

    <?php
    $image = get_field( 'image' );
    
    if( ! empty( $image )
       && function_exists( 'get_rocket_option' )
       && get_rocket_option( 'lazyload' 
    ) : ?>
    	<img src="data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=" data-lazy-src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    <?php elseif( ! empty( $image ) ) : ?>
    	<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    <?php endif; ?>

    Looks like you changed the function get_rocket_option to rocket_lazyload_get_option and split the options to images etc…

    It’s also an incomplete solution, the above suggested code doesn’t include the noscript tag for visitors not using javascript as well.

    Working on the code now for my theme, if you have an up to date solution would save me time if you have an up to date solution?

    Thanks…

Viewing 1 replies (of 1 total)
  • Thread Starter David Cameron Law

    (@seo-dave)

    figured out a much better solution to the manual support above. Couldn’t get the above to work in a way that created responsive images or the noscript code anyway.

    Filtered my custom image function with:

    apply_filters( 'post_thumbnail_html', custom_theme_image_function(.........) );

    Since Rocket LazyLoad adds a filter to post_thumbnail_html the lazyload code is added to the custom image function, no need for manual support.

Viewing 1 replies (of 1 total)
  • The topic ‘Out of Date Documentation on Rocket LazyLoad Plugin’ is closed to new replies.