Media: Ensure that HTML5 captions apply the `'img_caption_shortcode_width'`.
Props joemcgill. Fixes #31053. Built from https://develop.svn.wordpress.org/trunk@34261 git-svn-id: http://core.svn.wordpress.org/trunk@34225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f3dd19c6e2
commit
1f3dce8c75
|
@ -909,12 +909,9 @@ function img_caption_shortcode( $attr, $content = null ) {
|
||||||
|
|
||||||
$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
|
$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
|
||||||
|
|
||||||
if ( current_theme_supports( 'html5', 'caption' ) ) {
|
$html5 = current_theme_supports( 'html5', 'caption' );
|
||||||
return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">'
|
// HTML5 captions never added the extra 10px to the image width
|
||||||
. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
|
$width = $html5 ? $atts['width'] : ( 10 + $atts['width'] );
|
||||||
}
|
|
||||||
|
|
||||||
$caption_width = 10 + $atts['width'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the width of an image's caption.
|
* Filter the width of an image's caption.
|
||||||
|
@ -926,19 +923,27 @@ function img_caption_shortcode( $attr, $content = null ) {
|
||||||
*
|
*
|
||||||
* @see img_caption_shortcode()
|
* @see img_caption_shortcode()
|
||||||
*
|
*
|
||||||
* @param int $caption_width Width of the caption in pixels. To remove this inline style,
|
* @param int $width Width of the caption in pixels. To remove this inline style,
|
||||||
* return zero.
|
* return zero.
|
||||||
* @param array $atts Attributes of the caption shortcode.
|
* @param array $atts Attributes of the caption shortcode.
|
||||||
* @param string $content The image element, possibly wrapped in a hyperlink.
|
* @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 = '';
|
$style = '';
|
||||||
if ( $caption_width )
|
if ( $caption_width )
|
||||||
$style = 'style="width: ' . (int) $caption_width . 'px" ';
|
$style = 'style="width: ' . (int) $caption_width . 'px" ';
|
||||||
|
|
||||||
return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
|
$html = '';
|
||||||
. do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>';
|
if ( $html5 ) {
|
||||||
|
$html = '<figure ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
|
||||||
|
. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
|
||||||
|
} else {
|
||||||
|
$html = '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
|
||||||
|
. do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_shortcode('gallery', 'gallery_shortcode');
|
add_shortcode('gallery', 'gallery_shortcode');
|
||||||
|
@ -2778,7 +2783,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$attached_file = get_attached_file( $attachment->ID );
|
$attached_file = get_attached_file( $attachment->ID );
|
||||||
|
|
||||||
if ( isset( $meta['filesize'] ) ) {
|
if ( isset( $meta['filesize'] ) ) {
|
||||||
$bytes = $meta['filesize'];
|
$bytes = $meta['filesize'];
|
||||||
} elseif ( file_exists( $attached_file ) ) {
|
} elseif ( file_exists( $attached_file ) ) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34260';
|
$wp_version = '4.4-alpha-34261';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue