Make WordPress Core


Ignore:
Timestamp:
07/07/2023 06:06:49 PM (8 months ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r56154 r56164  
    56675667         * Skip programmatically created images within post content as they need to be handled together with the other
    56685668         * images within the post content.
    5669          * Without this clause, they would already be counted below which skews the number and can result in the first
    5670          * post content image being lazy-loaded only because there are images elsewhere in the post content.
     5669         * Without this clause, they would already be considered below which skews the image count and can result in
     5670         * the first post content image being lazy-loaded or an image further down the page being marked as a high
     5671         * priority.
    56715672         */
    56725673        if ( doing_filter( 'the_content' ) ) {
    5673             return $postprocess( $loading_attrs, true );
     5674            return $loading_attrs;
    56745675        }
    56755676
Note: See TracChangeset for help on using the changeset viewer.