Opened 10 years ago
Closed 9 years ago
#31053 closed enhancement (fixed)
HTML5 caption disregards img_caption_shortcode_width filter
Reported by: | trysmudford | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
In /wp-includes/media.php in the img_caption_shortcode function, the img_caption_shortcode_width filter is applied after the HTML5 caption has been returned, thus not setting the developer specified width.
I propose lines 875 to 879 should be moved above the HTML5 conditional on line 853 and it should only apply the $style variable, not hard-code the style attribute onto the element itself.
Attachments (1)
Change History (7)
#2
@
10 years ago
Just to jump in - that seems crazy.
So let me get this straight. If a theme author does not define HTML5 captions, they have the power to override the inline width, or even remove the inline style completely.
Yet with HTML5, they have nothing (at least not without overriding the shortcode handler).
I completely understand the removal of the 10 pixel padding, but not bypassing the filter entirely.
If anything, defining HTML5 caption support is an indication that the theme is responsive and far more likely to apply granular control over images and captions.
#3
@
10 years ago
- Type changed from defect (bug) to enhancement
Is there no comment on this? If backwards-compat is an issue, introduce a new filter. WordPress should not be forcing theme authors to override the shortcode handler simply to remove the inline style width.
#4
@
9 years ago
- Keywords has-patch dev-feedback added
I agree, the current behavior is less than ideal. Currently, if someone wants to use the HTML5 markup for image captions and filter out the inline style attribute, they would have to hook in early on at the img_caption_shortcode
filter and recreate the HTML wrapper themselves. I've added a patch that would respect the removal of the extra 10px from the caption width from HTML5 captions, while still allowing the img_caption_shortcode_width
filter to apply.
That's intentional, see [27668].