[Resolved] First image in content not lazy load

Home Forums Support [Resolved] First image in content not lazy load

Home Forums Support First image in content not lazy load

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2325735
    maxime

    Hello,

    Unlike most of what I found in the Support I would like to add a lazy load.
    I’m not using any plugin, just the lazy=loading from WordPress.
    But I found out that the first image in the article is never lazy load, to be clear I’m not talking about the featured image that appears on top of an article (I found a PHP code to not lazy load this image in the support and it seems to work), I’m talking about the first image that appears in the content. You can check every post I have, the first image in the content is never lazy load.

    Do you know how it could be possible to add a lazy load to this specific image for every post ? But also is it a generatepress or wordpress problem ? Cause if it’s wordpress then don’t worry.

    Thank you.

    #2326161
    David
    Staff
    Customer Support

    Hi there,

    the images in your single post content are being converted to picture elements for the purpose of loading WebP images.
    Which service are you using to do this ? As you may need to check with their support how to ensure native lazy loading is maintained.

    #2326370
    maxime

    Hello David,

    I’m using Imagify. But still that’s weird that the only one would be not lazy load if all image are picture.
    Or else, which plugin would you advise to use ?

    Thank you

    #2326399
    maxime

    I changed a setting, if you can check please and let me know how does it look for you and what can be done more. But it seems like it’s not webp anymore.

    Edit: I changed back the setting, I don’t think it’s worth it to lose the nextgen format for images.

    #2326504
    maxime

    I’ll look into it through different plugins and such. If it’s not something from generatepress it’s okay πŸ™‚

    If I can ask for one last thing. I don’t use a plugin to lazy load images so I would like to know if a PHP code exist to remove the lazy load from the Author picture in the Element Single post page hero (but it’s not a dynamic picture that I have, I changed it).

    Thank you.

    #2326526
    Ying
    Staff
    Customer Support

    so I would like to know if a PHP code exist to remove the lazy load from the Author picture in the Element Single post page hero

    1. Add this snippet:

    add_filter( 'wp_img_tag_add_loading_attr', 'skip_lazy_load', 10, 3 );
    
    function skip_lazy_load( $value, $image, $context ) {
    	if ( strpos( $image, 'no-lazy' ) !== false ) $value = '';
    
    	return $value;
    }

    2. Add no-lazy class to the GB image block:
    https://www.screencast.com/t/CnhmvAEoI

    #2326614
    maxime

    Perfect, thank you Ying πŸ™‚

    #2327454
    Ying
    Staff
    Customer Support

    No problem πŸ™‚

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