Make WordPress Core


Ignore:
Timestamp:
02/13/2023 06:32:40 PM (19 months ago)
Author:
flixos90
Message:

Media: Enhance logic to determine LCP image in block themes and avoid lazy-loading it.

[52065] originally introduced the logic to guess the LCP image based on certain heuristics and to not lazy-load that image. However, with the introduction of block themes, that logic was not functioning correctly, resulting in all featured images to be lazy-loaded, regardless of whether it was the LCP image or not.

Together with an update to the core/post-featured-image block included in [55079], this changeset fixes the logic to correctly handle featured images in block themes as well.

Additionally, in combination with an update to the core/template-part block from [55246], this changeset includes an enhancement which uses the benefits of block template parts to avoid lazy-loading images in the header block template part, making the lazy-loading heuristics even more accurate for sites using a block theme.

Props flixos90, adamsilverstein, mamaduka, antonvlasenko, shahidul95, reduanmasud, costdev, mukesh27, ironprogrammer, manfcarlo, robinwpdeveloper, spacedmonkey.
Fixes #56930.

File:
1 edited

Legend:

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

    r54817 r55318  
    242242    $content = convert_smilies( $content );
    243243    $content = shortcode_unautop( $content );
    244     $content = wp_filter_content_tags( $content );
     244    $content = wp_filter_content_tags( $content, 'template' );
    245245    $content = do_shortcode( $content );
    246246    $content = str_replace( ']]>', ']]>', $content );
Note: See TracChangeset for help on using the changeset viewer.