[wp-trac] [WordPress Trac] #50367: Avoid layout shifting due to images not having dimension attributes

WordPress Trac noreply at wordpress.org
Thu Jun 25 18:43:41 UTC 2020


#50367: Avoid layout shifting due to images not having dimension attributes
--------------------------------------+-----------------------
 Reporter:  flixos90                  |       Owner:  flixos90
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:  5.5
Component:  Media                     |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------
Changes (by flixos90):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"48170" 48170]:
 {{{
 #!CommitTicketReference repository="" revision="48170"
 Media: Ensure images have dimensions to reduce layout shift and facilitate
 lazy-loading.

 This changeset ensures that attachment images which are inserted without
 `width` and `height` attributes still receive them in the frontend, to
 reduce cumulative layout shift. Adding the dimensions happens as part of
 the logic for adding `srcset` and `sizes` attributes, which already assume
 the specific width and height of the respective image.

 Images are now only lazy-loaded if they have `width` and `height`
 attributes present. While missing these attributes itself is what causes
 layout shifts, lazy-loading such images can make this problem more
 apparent to the user.

 Props adamsilverstein, westonruter.
 Fixes #50367. See #44427.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50367#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list