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

WordPress Trac noreply at wordpress.org
Thu Dec 27 21:45:28 UTC 2018


#40299: Removing width attribute on an image with a caption removes entire caption
--------------------------+------------------------------
 Reporter:  catchmyfame   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  4.7.3
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Description changed by SergeyBiryukov:

Old description:

> 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

New description:

 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 [27426] and #23103.

--

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


More information about the wp-trac mailing list