Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 19 months ago

#56043 closed defect (bug) (duplicate)

WordPress core Lazy Loading filters don't work on featured images

Reported by: culturalistpress's profile culturalistpress Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.0
Component: Media Keywords:
Focuses: performance Cc:


Running wordpress 6.0 none of the filters or workarounds actually can fix the issue of WordPress lazy loading featured above the fold images.

This tanks page performance and there is no workaround available yet.

By default the lazy load on "featured images" isn't helped by make eager because its above the fold, it FCP a ton. The filter to remove the Lazy load entirely fails on featured images.

Change History (5)

#1 @mitogh
22 months ago

Thanks for your report @culturalistpress do you mind sharing a bit more a series of steps to replicate your problem and what theme are you using as well.

Have you tried to debug in a new installation with the default theme or with no additional plugins as well?

Thanks again for taking the time to report this problem.

#2 @culturalistpress
22 months ago

I have tried a new installation, I haven't really bothered with a default theme as I am running Neve.

You can see the impact even when the theme doesn't leverage featured images, just a default blog layout. For example:

The LCP tanks because the top images don't load until everything else is done.

I think you can replicate basically with any fresh WordPress installation after 5.7 using a default theme and loading some images in posts above the fold. In this case they are all set inside of posts as featured images.

#3 @ironprogrammer
22 months ago

  • Keywords reporter-feedback added

Thanks for the report, @culturalistpress!

This looks like this may be related to (or a duplicate of) #56002, where the filter in question is actually wp_img_tag_add_loading_attr (documentation link).

Would you please confirm if this addresses the issue?

#4 @johnbillion
22 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing this as a duplicate of #56002. There was a documentation error for the filters which has been corrected. Feel free to reopen this ticket if that's not the issue.

#5 @gilbertococchi
19 months ago

I was able to reproduce this issue on some WordPress Themes.

My understanding is that when Themes use the_post_thumbnail method then the post-thumbnail-template.php class uses the [wp_get_attachment_image]( method that is not handled well by the [wp_get_loading_attr_default]( method.

I guess it may be feasible to increase the match on detecting Featured images by handling this case by not applying loading=lazy on the first iteration of the context wp_get_attachment_image.

Note: See TracTickets for help on using tickets.