Archived topic
Lazy Loading Featured image.
9 replies · Started by Mouse on May 26, 2021
Hi there, I want to lazy load featured images on all posts. I am currently using ezoic speed accelerator and not using any other cache plugin.
Can you please let me know how to remove the lazy loading on the featured image by looking at my website?
Would also like to know how to check if the lazy loading is being skipped or not.
I am currently using the following code but it does not seem to be loading the featured image first.
add_action( 'wp_head', function(){
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full');
echo '<link rel="preload" as="image" href="'.$featured_img_url.'"/>';
});
Can you please let me know what I can use in order to load the featured image first? so that the LCP be improved?
Thanks
Hi there,
you're images HTML is being adjusted - looks like Ezoic is performing some optimization. I would suggest you speak with Ezoic as they are changing the HTML and we cannot provide a code that will work with that.
Hi David... They were being modified but not anymore. How can I stop featured image from lazy loading now?
Hi there,
If it's the default lazyloading. Try adding this PHP.
// Disable WordPress Lazy Load
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
Hi, I am using autoptimize for lazy loading for now.
Disabled default lazy loading of wordpress as suggested by Elvin (Using Snippets plugin). Also used classes to be excluded in Autoptimize plugin like:
wp-post-image
and
featured-image
but they are still lazy loading.
I checked a couple of random posts and your Images are still being manipulated by another plugin / server function - It has this class: ezlazyloaded and its using data-ezsrcset for its src-set... can't say for sure but it looks like thats Ezoics doing ... as i said before speak to Ezoic support.
Alright Thankyou.
You're welcome