Site logo

[Resolved] lazy loading issue

Home Forums Support [Resolved] lazy loading issue

Home Forums Support lazy loading issue

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2525102
    Thomas

    Looks like a few people are going through the same thing but I didn’t want to piggyback onto someone else’s thread with solutions that might be more site by site specific.

    Like a lot of people, currently working on cwv’s and getting the lazy loading error which is impacting Largest Contentful Paint. Caching plugin is telling me it’s theme/wp related.

    Any ideas how to fix?

    Using Generate Press info theme with latest version of WP. Caching plugin is flying press.. having lazy loading turned on, but have offset the first 3 images above fold, and also have included my logo from exclude list.. issue seems to be the featured image.. link in private box below.

    Thanks!

    #2525120
    Ying
    Staff
    Customer Support

    Hi Thomas,

    Can you try adding a CSS class no-lazy to the GB image block which represents the feature image in your single post.

    The image block can be found at appearance > elements > post page hero.

    Then add this PHP snippet, so the WP lazyload attribute will be removed from all the images with no-lazy class:

    add_filter( 'wp_get_attachment_image_attributes', 'remove_lazy_load_attribute', 10, 3 );
    
    function remove_lazy_load_attribute( $attributes, $attachment, $size ) {
    	if ( isset( $attributes['class'] ) && strpos( $attributes['class'], 'no-lazy' ) !== false ) {
    		unset( $attributes['loading'] );
    	}
    
    	return $attributes;
    }
    #2526130
    Thomas

    Thanks for the reply. Let me know if I did this correctly and then will re-rest. Add n0-lazy to the additional css classes under advanced? and then add php snippet to customize/additional css?

    Thanks!

    #2526185
    David
    Staff
    Customer Support

    Hi there,

    The PHP Snippet cannot go in the Customizer.
    This doc explains how to add PHP:

    https://docs.generatepress.com/article/adding-php/

    #2526189
    Thomas

    ok, thanks… I am going to try and run without lazy loading to see what that does to scores. Would prefer not adding another plugin if possible.

    Not GPS fault, but since WP added LL to core its been nothing but a headache on scores.

    Thanks again!

    #2526190
    Thomas

    thanks!

    #2526201
    David
    Staff
    Customer Support

    You’re welcome

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