[wp-trac] [WordPress Trac] #50367: Avoid layout shifting due to images not having dimension attributes
WordPress Trac
noreply at wordpress.org
Fri Jun 26 03:01:42 UTC 2020
#50367: Avoid layout shifting due to images not having dimension attributes
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner: flixos90
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.5
Component: Media | Version:
Severity: normal | Resolution:
Keywords: needs-testing has-patch has-unit- | Focuses:
tests needs-dev-note |
-------------------------------------------------+-------------------------
Comment (by flixos90):
@joemcgill @azaozz I've updated the PR to introduce a new function
`wp_img_tag_add_width_and_height_attr()` which on a high level behaves
similarly like `wp_img_tag_add_srcset_and_sizes_attr()` and
`wp_img_tag_add_loading_attr()`. The part that is now common for
`wp_img_tag_add_width_and_height_attr()` and
`wp_img_tag_add_srcset_and_sizes_attr()` I've moved into a new utility
function `wp_image_src_get_dimensions()` - in actual usage and the way the
functions are run subsequently in most cases that function will only be
called once. If `width` and `height` attributes are not present, they will
be added by `wp_img_tag_add_srcset_and_sizes_attr()`, this way the
functionality doesn't need to run again as part of
`wp_img_tag_add_srcset_and_sizes_attr()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50367#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list