Twenty Twenty-One: Do not specify `loading=“eager”` for single post thumbnails.

While `loading=“eager”` is a supported alternative to omitting the attribute entirely, browsers follow the value of this attribute explicitly when specified.

Specifying `eager` would prevent the user from receiving any additional potential benefits implemented at the browser level, such as further mechanisms to automatically decide which elements to lazy-load.

Props flixos90, ryelle, poena.
Fixes #52139.
Built from https://develop.svn.wordpress.org/trunk@49860


git-svn-id: http://core.svn.wordpress.org/trunk@49579 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2020-12-21 18:39:03 +00:00
parent 1d3fd41977
commit b8e5751dd1
2 changed files with 3 additions and 3 deletions

View File

@ -190,8 +190,8 @@ if ( ! function_exists( 'twenty_twenty_one_post_thumbnail' ) ) {
<figure class="post-thumbnail">
<?php
// Thumbnail is loaded eagerly because it's going to be in the viewport immediately.
the_post_thumbnail( 'post-thumbnail', array( 'loading' => 'eager' ) );
// Lazy-loading attributes should be skipped for thumbnails since they are immediately in the viewport.
the_post_thumbnail( 'post-thumbnail', array( 'loading' => false ) );
?>
<?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?>
<figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption( get_post_thumbnail_id() ) ); ?></figcaption>

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-alpha-49859';
$wp_version = '5.7-alpha-49860';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.