Site logo

[Resolved] Remove- loading=”lazy”, tag for featured images

Home Forums Support [Resolved] Remove- loading=”lazy”, tag for featured images

Home Forums Support Remove- loading=”lazy”, tag for featured images

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1776619
    Manu

    Hi Generatepress team,
    Is there any way to remove loading=”lazy” for featured images on the single post?

    Thank You

    #1776727
    Elvin
    Staff
    Customer Support

    Hi there,

    The default WordPress lazyload doesn’t allow you to disable this specific to an image.

    Consider using a plugin to manage lazy loading on your site.

    Have plugins like WP Rocket set the lazy load for you, and then disable featured image lazy load by following their documentation here – https://docs.wp-rocket.me/article/15-disabling-lazy-load-on-specific-images

    #1870741
    Ryan

    I also had this question, in addition to possibly disabling it on an certain image class. This does seem to be possible at least for featured images like the original question. They have some documentation here https://make.wordpress.org/core/2020/07/14/lazy-loading-images-in-5-5/ but I can’t figure it out.

    #1871215
    David
    Staff
    Customer Support

    Hi there,

    try the code i provided here:

    https://generatepress.com/forums/topic/how-to-resize-featured-image-on-mobile/#post-1858309

    Although my interpretation is above the fold images should ‘ignore’ the lazy attribute:

    https://web.dev/browser-level-image-lazy-loading/#distance-from-viewport-thresholds

    But who knows 🙂

    #1873597
    Manu

    Hi,
    I don’t know whether this is the correct approach. Here is what I tried;

    First, I disabled the default Lazy load on WordPress using the code:

    
    add_filter( 'wp_lazy_loading_enabled', '__return_false' );
    

    Then enabled the lazy load images using a cache plugin/ optimization plugin. In my case, it is LiteSpeed Cache and excluded the featured image class from lazy loading.

    Correct me if I am doing something wrong.

    #1873652
    Elvin
    Staff
    Customer Support

    Then enabled the lazy load images using a cache plugin/ optimization plugin. In my case, it is LiteSpeed Cache and excluded the featured image class from lazy loading.

    That’s actually a good way of doing it. WP’s default lazy load is lacking so it’s better to replace it with a plugin with more control like Litespeed cache or WP Rocket that lets you target an image specifically through its class selector.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.