Opened 9 years ago
Last modified 8 years ago
#40299 new defect (bug)
Removing width attribute on an image with a caption removes entire caption
| Reported by: | catchmyfame | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Media | Version: | 4.7.3 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
Description (last modified by )
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In the recent Media component meeting we reviewed this issue and confirmed that the issue exists with the classic-editor plugin enabled but not in the classic-block available in Gutenberg. This is still valid for Classic Editor so we should leave this as
future releaseand this will need a patch. :)