diff --git a/wp-includes/media.php b/wp-includes/media.php index c4c8961b9f..a7db3213fd 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -909,12 +909,9 @@ function img_caption_shortcode( $attr, $content = null ) { $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); - if ( current_theme_supports( 'html5', 'caption' ) ) { - return ''; - } - - $caption_width = 10 + $atts['width']; + $html5 = current_theme_supports( 'html5', 'caption' ); + // HTML5 captions never added the extra 10px to the image width + $width = $html5 ? $atts['width'] : ( 10 + $atts['width'] ); /** * Filter the width of an image's caption. @@ -926,19 +923,27 @@ function img_caption_shortcode( $attr, $content = null ) { * * @see img_caption_shortcode() * - * @param int $caption_width Width of the caption in pixels. To remove this inline style, - * return zero. - * @param array $atts Attributes of the caption shortcode. - * @param string $content The image element, possibly wrapped in a hyperlink. + * @param int $width Width of the caption in pixels. To remove this inline style, + * return zero. + * @param array $atts Attributes of the caption shortcode. + * @param string $content The image element, possibly wrapped in a hyperlink. */ - $caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content ); + $caption_width = apply_filters( 'img_caption_shortcode_width', $width, $atts, $content ); $style = ''; if ( $caption_width ) $style = 'style="width: ' . (int) $caption_width . 'px" '; - return '