#56043 closed defect (bug) (duplicate)
WordPress core Lazy Loading filters don't work on featured images
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.0 |
Component: | Media | Keywords: | |
Focuses: | performance | Cc: |
Description
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.
https://make.wordpress.org/core/2020/01/29/lazy-loading-images-in-wordpress-core/
Change History (5)
#2
@
3 years 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:
https://pagespeed.web.dev/report?url=https%3A%2F%2Fwww.culturalistpress.com%2Fcategory%2Fhome-garden%2F
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
@
3 years 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
@
3 years 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
@
2 years 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](https://github.com/WordPress/WordPress/blob/1cd42e3cbe7890a891d7a37b6a7467188b3ef59e/wp-includes/post-thumbnail-template.php#L202) method that is not handled well by the [wp_get_loading_attr_default](https://github.com/WordPress/WordPress/blob/b90c2adb7f65b610c84db80fa35b66cc036e1a66/wp-includes/media.php#L5495-L5516) 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.
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.