Site logo

Archived topic

Disable lazy load of featured image.

3 replies · Started by Mark on August 19, 2022

Viewing posts 1–4 of 4

Hi,

My featured images for posts are pulled in using Elements, I made a 'Block - Page Hero' with dynamic data to pull in featured image and display above posts.

However, I would like to disable lazy-load for this image, to help with LCP.

Any ideas how I can do this?

Thanks!

Hi Ying,

Thanks, I tried this but it still seems to be adding loading=lazy.

Instead it now says:

"<img width="1030" height="401" src="REDACTED" class="gb-image-bec0fc6b skip-lazy" alt="" loading="lazy" srcset="REDACTED 1030w, REDACTED 300w, REDACTED 1024w, REDACTED 768w" sizes="(max-width: 1030px) 100vw, 1030px" />"

Any ideas?

Thanks!

EDIT: I solved this for now by disabling WP native lazyload with:

add_filter( 'wp_lazy_loading_enabled', '__return_false' );

In functions.php. I then used Autoptimize for lazy loading which gives you more control, e.g. don't lazy load the first X images, as well as the ability to exclude lazy loading by class, filename etc.

There may be a cleaner way of doing this while keeping WP native lazy loading.

Glad you found a way out :)

This archived topic is closed to new replies.