From 860b45216e0b2ffea853b1a00b4132aefcf07902 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Fri, 16 Mar 2018 20:06:41 +0000 Subject: [PATCH] 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 --- src/wp-includes/media.php | 2 +- tests/phpunit/tests/media.php | 4 ++-- tests/phpunit/tests/shortcode.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 8965da9ac2..614497a46b 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -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 ) { diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index e55a4cea97..f2961b8355 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -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 ) ); } } diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php index 5acd7e268f..3577fab338 100644 --- a/tests/phpunit/tests/shortcode.php +++ b/tests/phpunit/tests/shortcode.php @@ -535,7 +535,7 @@ EOF; ), array( '[caption caption="test" width="2"]
hello
[/caption]', - '
hello

test

', + '
hello

test

', ), array( '
',