- This topic has 7 replies, 3 voices, and was last updated 7 months ago by
Ying.
-
AuthorPosts
-
August 27, 2022 at 12:28 pm #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.
August 28, 2022 at 7:18 am #2326161David
StaffCustomer SupportHi 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.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/August 28, 2022 at 8:20 am #2326370maxime
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
August 28, 2022 at 8:50 am #2326399maxime
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.
August 28, 2022 at 11:21 am #2326504maxime
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.
August 28, 2022 at 12:01 pm #2326526Ying
StaffCustomer Supportso 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/CnhmvAEoIAugust 28, 2022 at 3:10 pm #2326614maxime
Perfect, thank you Ying π
August 29, 2022 at 9:57 am #2327454Ying
StaffCustomer SupportNo problem π
-
AuthorPosts
- You must be logged in to reply to this topic.