Changeset 55171
- Timestamp:
- 01/31/2023 07:39:51 PM (22 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r54802 r55171 1024 1024 * Defaults to 'lazy', depending on wp_lazy_loading_enabled(). 1025 1025 * @type string $decoding The 'decoding' attribute value. Possible values are 1026 * 'async' (default), 'sync', or 'auto'. 1026 * 'async' (default), 'sync', or 'auto'. Passing false or an empty 1027 * string will result in the attribute being omitted. 1027 1028 * } 1028 1029 * @return string HTML img element or empty string on failure. … … 1056 1057 1057 1058 $attr = wp_parse_args( $attr, $default_attr ); 1059 1060 // Omit the `decoding` attribute if the value is invalid according to the spec. 1061 if ( empty( $attr['decoding'] ) || ! in_array( $attr['decoding'], array( 'async', 'sync', 'auto' ), true ) ) { 1062 unset( $attr['decoding'] ); 1063 } 1058 1064 1059 1065 // If the default value of `lazy` for the `loading` attribute is overridden -
trunk/tests/phpunit/tests/media.php
r54891 r55171 3280 3280 3281 3281 /** 3282 * @ticket 57086 3283 * 3284 * @dataProvider data_wp_get_attachment_image_decoding_attr 3285 * 3286 * @covers ::wp_get_attachment_image 3287 */ 3288 public function test_wp_get_attachment_image_decoding_attr( $decoding, $expected ) { 3289 if ( 'no value' === $decoding ) { 3290 $image = wp_get_attachment_image( self::$large_id, 'thumbnail', false, array() ); 3291 } else { 3292 $image = wp_get_attachment_image( self::$large_id, 'thumbnail', false, array( 'decoding' => $decoding ) ); 3293 } 3294 3295 if ( 'no value' === $expected ) { 3296 $this->assertStringNotContainsString( ' decoding=', $image ); 3297 } else { 3298 $this->assertStringContainsString( ' decoding="' . esc_attr( $expected ) . '"', $image ); 3299 } 3300 } 3301 3302 /** 3303 * Data provider for test_wp_get_attachment_image_decoding_attr(). 3304 * 3305 * @return array[] 3306 */ 3307 public function data_wp_get_attachment_image_decoding_attr() { 3308 return array( 3309 'default' => array( 3310 'decoding' => 'no value', 3311 'expected' => 'async', 3312 ), 3313 'async' => array( 3314 'decoding' => 'async', 3315 'expected' => 'async', 3316 ), 3317 'sync' => array( 3318 'decoding' => 'sync', 3319 'expected' => 'sync', 3320 ), 3321 'auto' => array( 3322 'decoding' => 'auto', 3323 'expected' => 'auto', 3324 ), 3325 'empty' => array( 3326 'decoding' => '', 3327 'expected' => 'no value', 3328 ), 3329 'false' => array( 3330 'decoding' => false, 3331 'expected' => 'no value', 3332 ), 3333 'null' => array( 3334 'decoding' => null, 3335 'expected' => 'no value', 3336 ), 3337 'zero' => array( 3338 'decoding' => 0, 3339 'expected' => 'no value', 3340 ), 3341 'zero string' => array( 3342 'decoding' => '0', 3343 'expected' => 'no value', 3344 ), 3345 'zero float' => array( 3346 'decoding' => 0.0, 3347 'expected' => 'no value', 3348 ), 3349 'invalid' => array( 3350 'decoding' => 'invalid', 3351 'expected' => 'no value', 3352 ), 3353 ); 3354 } 3355 3356 /** 3282 3357 * @ticket 44427 3283 3358 * @ticket 50425
Note: See TracChangeset
for help on using the changeset viewer.