Make WordPress Core

Changeset 49861


Ignore:
Timestamp:
12/21/2020 06:49:22 PM (4 years ago)
Author:
desrosj
Message:

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.
Merges [49860] to the 5.6 branch.
Fixes #52139.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/src/wp-content/themes/twentytwentyone/inc/template-tags.php

    r49829 r49861  
    191191            <figure class="post-thumbnail">
    192192                <?php
    193                 // Thumbnail is loaded eagerly because it's going to be in the viewport immediately.
    194                 the_post_thumbnail( 'post-thumbnail', array( 'loading' => 'eager' ) );
     193                // Lazy-loading attributes should be skipped for thumbnails since they are immediately in the viewport.
     194                the_post_thumbnail( 'post-thumbnail', array( 'loading' => false ) );
    195195                ?>
    196196                <?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?>
Note: See TracChangeset for help on using the changeset viewer.