Archived topic
Remove- loading="lazy", tag for featured images
5 replies · Started by Manu on May 12, 2021
Hi Generatepress team,
Is there any way to remove loading="lazy" for featured images on the single post?
Thank You
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
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.
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 :)
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.
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.