Archived topic
First image lazy load exclusion
11 replies · Started by maxime on January 16, 2022
Hello,
I would like to not lazy load the first image (or featured image) on every page as I saw in this post.
So I copied and paste the PHP Snippet but it doesn't work, I think I have to do something with the CSS but I didn't understand how or where.
The PHP Snippets is actually active, just to let you know.
If there's another way to do it, please let me know too.
Thanks for your help.
Hi there,
That script is to add the class first-featured-image to the featured image and it's indeed working:
https://www.screencast.com/t/tOQBBYrtmMKn
Then you just need to add first-featured-image to the exclusion of whatever plugin you are using to perform lazy-load.
The theme itself doesn't have any lazy loading feature built-in so it must be from a plugin.
You can check with the plugin support for further info if needed.
Hello Leo, sorry for the late reply I didn't check back.
Thank you I understand now how the code works :)
I'm using imagify but I don't see any lazy load option and for the plugin autoptimize, in the image section I didn't check any box about image optimization nor the lazy load.
Which mean that I think my image are being lazy load automatically by WordPress now that they do that and we don't need any plugin.
By any chance would you know how I can exclude then the first image lazy load not caused by a plugin?
Thanks
Hi Maxime,
It looks like you are using WP fastest cache plugin, can you check if it has lazy load options?
And for Autoptimize, you can find its lazyload settings at settings > Autoptimize > images, you can see the exclusions options there.
Hello Ying,
For WP fastest cache it's unchecked and I can't even check it cause I don't have the premium plan haha
But for Autoptimize it means I would have to activate the lazy load to then exclude the class first-featured-image ?
Because right now my lazy load are just from WordPress itself.
Because right now my lazy load are just from WordPress itself.
Hmm in that case can you check with WordPress' support team to see if they can help to exclude certain images from being lazy loaded?
I did a quick research but can only find this:
https://www.wppagebuilders.com/disable-lazy-load-in-wordpress-5-5/
Understood Leo, thank you for your help.
And Ying to let you know that it's working when autoptimize activated and the class Leo told me excluded.
Anyway I looked in case of in your link.
Thank you both, have a nice day.
You can try a plugin to disable Wordpress native lazy load: https://wordpress.org/plugins/disable-lazy-loading/
Or give this filter a try to disable WP lazy load:
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
As it's not a GP issue, it's better to reach out to WP support.
I did some Googling, this article should be helpful: https://wphelp.blog/how-to-selectively-disable-lazy-load/
Thank you Ying I'll try that first :)
And Ying to let you know that it’s working when autoptimize activated and the class Leo told me excluded.
Hmm in that case I would assume Autopimize is responsible for the lazy loading and not WordPress.
Glad to hear it's working for you though!
Yes I activated the lazy loading from autoptimize to try its exclusion, and it's working :)
So I think I'll have to disable the native lazy load from WordPress
Sounds good :)