[wp-trac] [WordPress Trac] #40299: Removing width attribute on an image with a caption removes entire caption

WordPress Trac noreply at wordpress.org
Wed Mar 29 13:59:24 UTC 2017


#40299: Removing width attribute on an image with a caption removes entire caption
--------------------------+-----------------------------
 Reporter:  catchmyfame   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  4.7.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 If you insert an image with a caption into the visual editor, it will
 create code like:

 {{{
 [caption id="attachment_12345" align="alignnone" width="150"]<img class
 ="wp-image-12345 size-thumbnail" src="https://www.example.com/wp-
 content/uploads/2017/03/image.png" alt="" width="150" height="150" /> My
 caption[/caption]
 }}}

 If you switch from the visual editor to the text editor and remove the
 `width` attribute '''of the image''' to get:

 {{{
 [caption id="attachment_12345" align="alignnone" width="150"]<img class
 ="wp-image-12345 size-thumbnail" src="https://www.example.com/wp-
 content/uploads/2017/03/image.png" alt="" height="150" /> My
 caption[/caption]
 }}}

 And then either update the post, or switch back to the visual editor, the
 caption is stripped and only the image remains:

 {{{
 <img class="wp-image-12345 size-thumbnail" src="https://www.example.com
 /wp-content/uploads/2017/03/image.png" alt="" height="150" />
 }}}

 Removing the `height` attribute doesn't appear to cause the same behavior.
 I don't believe that removing the width attribute on the image should
 result in both the caption being stripped and the `[caption]` shortcode
 being removed.

 I'm not sure but this might be related to
 https://core.trac.wordpress.org/changeset/27426 and
 https://core.trac.wordpress.org/ticket/23103

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40299>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list