diff --git a/wp-includes/block-template.php b/wp-includes/block-template.php index 19f3b5fb14..4d5742a4b9 100644 --- a/wp-includes/block-template.php +++ b/wp-includes/block-template.php @@ -241,7 +241,7 @@ function get_the_block_template_html() { $content = wptexturize( $content ); $content = convert_smilies( $content ); $content = shortcode_unautop( $content ); - $content = wp_filter_content_tags( $content ); + $content = wp_filter_content_tags( $content, 'template' ); $content = do_shortcode( $content ); $content = str_replace( ']]>', ']]>', $content ); diff --git a/wp-includes/media.php b/wp-includes/media.php index 01062855a1..95836d98a2 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -5444,25 +5444,40 @@ function wp_get_webp_info( $filename ) { * that the `loading` attribute should be skipped. */ function wp_get_loading_attr_default( $context ) { - // Only elements with 'the_content' or 'the_post_thumbnail' context have special handling. - if ( 'the_content' !== $context && 'the_post_thumbnail' !== $context ) { - return 'lazy'; - } - - // Only elements within the main query loop have special handling. - if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { - return 'lazy'; - } - - // Increase the counter since this is a main query content element. - $content_media_count = wp_increase_content_media_count(); - - // If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted. - if ( $content_media_count <= wp_omit_loading_attr_threshold() ) { + // Skip lazy-loading for the overall block template, as it is handled more granularly. + if ( 'template' === $context ) { return false; } - // For elements after the threshold, lazy-load them as usual. + // Do not lazy-load images in the header block template part, as they are likely above the fold. + $header_area = WP_TEMPLATE_PART_AREA_HEADER; + if ( "template_part_{$header_area}" === $context ) { + return false; + } + + /* + * The first elements in 'the_content' or 'the_post_thumbnail' should not be lazy-loaded, + * as they are likely above the fold. + */ + if ( 'the_content' === $context || 'the_post_thumbnail' === $context ) { + // Only elements within the main query loop have special handling. + if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { + return 'lazy'; + } + + // Increase the counter since this is a main query content element. + $content_media_count = wp_increase_content_media_count(); + + // If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted. + if ( $content_media_count <= wp_omit_loading_attr_threshold() ) { + return false; + } + + // For elements after the threshold, lazy-load them as usual. + return 'lazy'; + } + + // Lazy-load by default for any unknown context. return 'lazy'; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 207d835fb9..bc93f71c10 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-beta1-55317'; +$wp_version = '6.2-beta1-55318'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.