Media: Avoid programmatically created images within post content from incorrectly receiving fetchpriority="high".

Follow-up to [56037], as that changeset accidentally did not consider the changes made in [55825]: Images that are programmatically injected into post content (e.g. through a block, or shortcode, or any hook calling a function like `wp_get_attachment_image()`) must be treated as part of the whole post content blob since otherwise the heuristics for applying `fetchpriority="high"` and `loading="lazy"` are skewed by parsing certain images before others rather than sequentially parsing the entire post content. [55825] addressed that for lazy-loading, but when [56037] introduced `fetchpriority` support, the related refactor missed making the same consideration for that attribute.

Props flixos90, spacedmonkey, thekt12, mukesh27.
Fixes #58235.
See #58089.

Built from https://develop.svn.wordpress.org/trunk@56164


git-svn-id: http://core.svn.wordpress.org/trunk@55676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2023-07-07 18:08:24 +00:00
parent ea399e28a9
commit bb8ad05161
2 changed files with 5 additions and 4 deletions

View File

@ -5666,11 +5666,12 @@ function wp_get_loading_optimization_attributes( $tag_name, $attr, $context ) {
/*
* Skip programmatically created images within post content as they need to be handled together with the other
* images within the post content.
* Without this clause, they would already be counted below which skews the number and can result in the first
* post content image being lazy-loaded only because there are images elsewhere in the post content.
* Without this clause, they would already be considered below which skews the image count and can result in
* the first post content image being lazy-loaded or an image further down the page being marked as a high
* priority.
*/
if ( doing_filter( 'the_content' ) ) {
return $postprocess( $loading_attrs, true );
return $loading_attrs;
}
// Conditionally skip lazy-loading on images before the loop.

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-beta3-56163';
$wp_version = '6.3-beta3-56164';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.