Revert max-width styles on caption shortcodes.

This is a partial revert of [41724], so image captions include an
inline `width` style instead of `max-width`.

This returns the caption shortcode to the pre-4.9.0 behavior, while
retaining the extra unit test coverage added in [41724].

Fixes #43123. See #33981.


git-svn-id: https://develop.svn.wordpress.org/trunk@42837 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe McGill 2018-03-16 20:06:41 +00:00
parent 8e4bd924d2
commit 860b45216e
3 changed files with 4 additions and 4 deletions

View File

@ -1603,7 +1603,7 @@ function img_caption_shortcode( $attr, $content = null ) {
$style = '';
if ( $caption_width ) {
$style = 'style="max-width: ' . (int) $caption_width . 'px" ';
$style = 'style="width: ' . (int) $caption_width . 'px" ';
}
if ( $html5 ) {

View File

@ -132,9 +132,9 @@ CAP;
$this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );
if ( current_theme_supports( 'html5', 'caption' ) ) {
$this->assertEquals( 1, preg_match_all( '/max-width: 20/', $result, $_r ) );
$this->assertEquals( 1, preg_match_all( '/width: 20/', $result, $_r ) );
} else {
$this->assertEquals( 1, preg_match_all( '/max-width: 30/', $result, $_r ) );
$this->assertEquals( 1, preg_match_all( '/width: 30/', $result, $_r ) );
}
}

View File

@ -535,7 +535,7 @@ EOF;
),
array(
'[caption caption="test" width="2"]<div>hello</div>[/caption]',
'<div style="max-width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>',
'<div style="width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>',
),
array(
'<div [gallery]>',