Ticket #33981: 33981.3.patch
File 33981.3.patch, 3.5 KB (added by , 7 years ago) |
---|
-
src/wp-includes/media.php
1578 1578 1579 1579 $style = ''; 1580 1580 if ( $caption_width ) { 1581 $style = 'style=" width: ' . (int) $caption_width . 'px" ';1581 $style = 'style="max-width: ' . (int) $caption_width . 'px" '; 1582 1582 } 1583 1583 1584 1584 if ( $html5 ) { -
tests/phpunit/tests/media.php
23 23 function setUp() { 24 24 parent::setUp(); 25 25 $this->caption = 'A simple caption.'; 26 $this->alternate_caption = 'Alternate caption.'; 26 27 $this->html_content = <<<CAP 27 28 A <strong class='classy'>bolded</strong> <em>caption</em> with a <a href="#">link</a>. 28 29 CAP; … … 46 47 $this->assertNull( $result ); 47 48 } 48 49 49 function test_img_caption_shortcode_with_bad_attr() { 50 $result = img_caption_shortcode( array(), 'content' ); 51 $this->assertEquals( 'content', 'content' ); 50 /** 51 * @ticket 33981 52 */ 53 function test_img_caption_shortcode_with_empty_params_but_content() { 54 $result = img_caption_shortcode( array(), $this->caption ); 55 $this->assertEquals( $this->caption, $result ); 56 } 57 58 /** 59 * @ticket 33981 60 */ 61 function test_img_caption_shortcode_short_circuit_filter() { 62 add_filter( 'img_caption_shortcode', function() { 63 return $this->alternate_caption; 64 }); 65 66 $result = img_caption_shortcode( array(), $this->caption ); 67 $this->assertEquals( $this->alternate_caption, $result ); 68 } 69 70 /** 71 * @ticket 33981 72 */ 73 function test_img_caption_shortcode_empty_width() { 74 $result = img_caption_shortcode( 75 array( 76 'width' => 0, 77 ), 78 $this->caption 79 ); 80 $this->assertEquals( $this->caption, $result ); 81 } 82 83 /** 84 * @ticket 33981 85 */ 86 function test_img_caption_shortcode_empty_caption() { 87 $result = img_caption_shortcode( 88 array( 89 'caption' => '', 90 ) 91 ); 92 $this->assertNull( $result ); 93 } 94 95 /** 96 * @ticket 33981 97 */ 98 function test_img_caption_shortcode_empty_caption_and_content() { 99 $result = img_caption_shortcode( 100 array( 101 'caption' => '', 102 ), 103 $this->caption 104 ); 105 $this->assertEquals( $this->caption, $result ); 52 106 } 53 107 54 108 function test_img_caption_shortcode_with_old_format() { … … 61 115 $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 62 116 63 117 if ( current_theme_supports( 'html5', 'caption' ) ) { 64 $this->assertEquals( 1, preg_match_all( "/ width: 20/", $result, $_r ) );118 $this->assertEquals( 1, preg_match_all( "/max-width: 20/", $result, $_r ) ); 65 119 } else { 66 $this->assertEquals( 1, preg_match_all( "/ width: 30/", $result, $_r ) );120 $this->assertEquals( 1, preg_match_all( "/max-width: 30/", $result, $_r ) ); 67 121 } 68 122 } 69 123 … … 81 135 $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 82 136 } 83 137 138 function test_img_caption_shortcode_with_old_format_and_class() { 139 $result = img_caption_shortcode( 140 array( 141 'width' => 20, 142 'class' => 'some-class another-class', 143 'caption' => $this->caption, 144 ) 145 ); 146 $this->assertEquals( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) ); 147 148 } 149 84 150 function test_new_img_caption_shortcode_with_html_caption() { 85 151 $result = img_caption_shortcode( 86 152 array( 'width' => 20, 'caption' => $this->html_content )