[wp-trac] [WordPress Trac] #55229: Super broad selector for images max-width on WP 5.9

WordPress Trac noreply at wordpress.org
Tue Feb 22 22:29:20 UTC 2022


#55229: Super broad selector for images max-width on WP 5.9
--------------------------+------------------------------
 Reporter:  hvianna       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Formatting    |     Version:  5.9.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  css
--------------------------+------------------------------

Comment (by joyously):

 I'm not saying that core styles should have this rule, but it ''is'' a
 recommended practice for themes, even without using `object-fit: contain`.
 Since there was a gap in core, when the height and width attributes were
 not output, your images could have have them or not. When using `height:
 auto`, this overrides any height attribute that is in the HTML, leaving
 the width as either the attribute or the CSS (if specified in the theme).
 Your theme should make sure all images are styled correctly, whether there
 are attributes or not. CSS overrides attributes, so it makes more sense to
 **not** specify width rules, and let the image-specific attribute dictate
 the width, since the width is chosen by the user for each image.

 There was another ticket which was to make sure the width and height
 attributes were output. When that one was fixed, a lot of people
 complained because the images were distorted. They needed the style in
 question to fix it.

 I'm surprised it is `html :where(img)` instead of just `img`.

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


More information about the wp-trac mailing list