[wp-trac] [WordPress Trac] #49601: layout width bugfix for img_caption_shortcode()

WordPress Trac noreply at wordpress.org
Mon Mar 9 01:08:45 UTC 2020


#49601: layout width bugfix for img_caption_shortcode()
------------------------------------+-----------------------
 Reporter:  joelhardi               |       Owner:  (none)
     Type:  defect (bug)            |      Status:  reopened
 Priority:  normal                  |   Milestone:
Component:  Media                   |     Version:  trunk
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+-----------------------

Comment (by joelhardi):

 I would have suggested removing inline styles completely but I know that
 would break people's layouts. (It seems like a hack for core to be
 hardcoding styles inline, it should be left to each theme's CSS to apply
 styles, and this `width` inline style seems unnecessary. If the only point
 was to make the caption the same width as the image, CSS alone can do that
 without hardcoding any pixel values anywhere.)

 So, goal of the patch is just to incrementally improve core even if this
 technical debt can't be eliminated completely. Using `max-width` is better
 than hardcoding `width`, and moving this to the caption element is better
 than the container (it addresses your issue in #43123).

 This way the core behavior is improved. With the patch it's actually no
 longer necessary to put `.wp-caption {max-width:100%;}` into themes as a
 workaround for the hardcoded width.

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


More information about the wp-trac mailing list