[wp-trac] [WordPress Trac] #62413: WordPress 6.7 Auto-sizes Reducing Image Sizes

WordPress Trac noreply at wordpress.org
Fri Nov 15 21:58:17 UTC 2024


#62413: WordPress 6.7 Auto-sizes Reducing Image Sizes
-------------------------------------------------+-------------------------
 Reporter:  dooperweb                            |       Owner:  joemcgill
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.7.1
Component:  Media                                |     Version:  6.7
 Severity:  normal                               |  Resolution:
 Keywords:  has-testing-info has-patch has-      |     Focuses:
  unit-tests needs-refresh                       |  performance
-------------------------------------------------+-------------------------

Comment (by flixos90):

 @joemcgill pointed out to me that the problem can also occur for sites
 that use `width: auto` for images in CSS.

 As such, I queried HTTP Archive for that and unfortunately (though as I
 would expect) the usage of that is not a trivial amount. Between 15-20% of
 WordPress sites have at least one image with that CSS rule applied. The
 overall % of images across WordPress sites is between 7-9%, so that means
 by far not every image is affected, but some images. In any case, these
 percentages are ''a lot'' higher than those for `width: fit-content`, so
 for that I don't think a filter to opt out is sufficient (though that's
 still worth exploring).

 That said, a revert still does not seem right if we can come up with a
 fix, because >80% of WordPress sites still benefit from this feature
 without any side effects.

 A good solution we discussed via DM would be to override the user agent
 stylesheet rule for `   contain-intrinsic-size`. By setting those
 constraints to much larger values, we would avoid the visual problem for
 any of the sites. Needless to say, it should still be discouraged to use
 `width: auto` and `width: fit-content` in favor of better ways to
 constrain images, but for the themes that use that today this workaround
 would address the problems, without negatively impacting all the sites
 that aren't affected by the problem.

 Specifically, we could include this in `wp_head`:
 {{{
 img:is([sizes="auto" i], [sizes^="auto," i]) {
     contain-intrinsic-size: 3000px 1500px;
 }
 }}}

 These values are 10x the default and they are large enough that almost no
 images (probably <1% of images) would still be downsized.

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


More information about the wp-trac mailing list