[wp-trac] [WordPress Trac] #56588: WordPress puts "loading=lazy" on first image on archive page - wp_get_loading_attr_default bug
WordPress Trac
noreply at wordpress.org
Tue May 23 18:24:15 UTC 2023
#56588: WordPress puts "loading=lazy" on first image on archive page -
wp_get_loading_attr_default bug
-------------------------------------------------+-------------------------
Reporter: salvoaranzulla | Owner: flixos90
Type: defect (bug) | Status: closed
Priority: high | Milestone: 6.3
Component: Media | Version: 5.9
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests has- | Focuses:
testing-info | performance
-------------------------------------------------+-------------------------
Changes (by flixos90):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"55850" 55850]:
{{{
#!CommitTicketReference repository="" revision="55850"
Media: Fix lazy-loading bug by avoiding to modify content images when
creating an excerpt.
The `wp_filter_content_tags()` function, which modifies image tags for
example to optimize performance, is hooked into the `the_content` filter
by default. When rendering an excerpt for a post that doesn't have a
manually provided excerpt, the post content is used to generate the
excerpt, handled by the `wp_trim_excerpt()` function.
Prior to this changeset, this led to `wp_filter_content_tags()` being
called on the content when generating the excerpt, which is wasteful as
all tags are stripped from the excerpt, and it furthermore could result in
a lazy-loading bug when the post content contained images, as those images
were being counted even though they would never be rendered as part of the
excerpt.
This changeset fixes the bug and slightly improves performance for
generating an excerpt by temporarily unhooking the
`wp_filter_content_tags()` function from the `the_content` filter when
using it to generate the excerpt.
Props costdev, flixos90, joemcgill, mukesh27, salvoaranzulla,
spacedmonkey, thekt12, westonruter.
Fixes #56588.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56588#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list