Opened 12 years ago
Closed 11 years ago
#23103 closed enhancement (fixed)
Image caption shortcode without a width is lost
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.9 | Priority: | low |
Severity: | normal | Version: | 3.4 |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
- Add the line in text editor
[caption caption="test" width="300"]Checkuot this text[/caption]
- switch to visual editor
- switch back to text and you get
<dl class="wp-caption alignnone" id="" style="width: 310px;"><dt class="wp-caption-dt">Checkuot this text</dt><dd class="wp-caption-dd">test</dd></dl>
Change History (8)
#2
@
12 years ago
Seems related, though I haven't checked pre-3.5. If you have a normal captioned image, but remove the width attribute, for example:
[caption id="attachment_67" align="alignnone" width="300"] <img class="size-medium wp-image-67" alt="caption" src="http://local.dev/stable/wp-content/uploads/2012/11/cropped-tree-300x149.png" height="149" /> caption[/caption]
Then switching to visual and back strips away the shortcode entirely leaving you with:
<img class="size-medium wp-image-67" alt="caption" src="http://local.dev/stable/wp-content/uploads/2012/11/cropped-tree-300x149.png" height="149" />
#3
follow-ups:
↓ 4
↓ 6
@
11 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
The caption shortcode is specifically for adding captions to images. If no image exists the shortcode is removed. Removing it works as expected now, doesn't leave behind any html tags.
If you have a normal captioned image, but remove the width ...
Yes, the captions require the width attribute. We probably can recreate the caption width from the image tag width
, but don't see why the width was removed from the caption in the first place.
#4
in reply to:
↑ 3
@
11 years ago
- Milestone set to Future Release
- Priority changed from normal to low
- Summary changed from Non image caption shortcode lost when switching from text to visual editor and back to Image caption shortcode without a width is lost
- Type changed from defect (bug) to enhancement
Replying to azaozz:
Yes, the captions require the width attribute. We probably can recreate the caption width from the image tag
width
, but don't see why the width was removed from the caption in the first place.
I think it would be reasonable to do this. Wouldn't it also make it easier to insert a caption shortcode manually?
#6
in reply to:
↑ 3
;
follow-up:
↓ 7
@
11 years ago
Replying to azaozz:
Yes, the captions require the width attribute. We probably can recreate the caption width from the image tag
width
, but don't see why the width was removed from the caption in the first place.
I believe the width is removed in regard to responsive designs. Both the height and width attribute in both images inserted and the caption shortcode makes this a challenge.
Couldn't we set the width of it to the captioned image wrapper, and make it filterable?
And with image sizes, are the width and height attributes required when Full Size is selected? I can see the use for Thumbnail, Medium etc, but it just seems redundant on the full one?
#7
in reply to:
↑ 6
@
11 years ago
- Milestone changed from Future Release to 3.9
Replying to Clorith:
This affects only displaying the captions inside the Visual editor. For the front-end the HTML can be overridden with the 'img_caption_shortcode'
filter.
The width and height attributes on <img> are considered HTML best practice as they let the browser allocate the space for the image before it has started downloading and prevent all the page's content from jumping and shifting, especially on slower connections.
Reproduced in 3.4 as well. In 3.3 and earlier, only "Checkout this text" remains.