Changeset 59954
- Timestamp:
- 03/09/2025 09:14:28 AM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r59865 r59954 3483 3483 $attr_strings = array(); 3484 3484 3485 foreach ( $html_atts as $k => $v ) { 3486 $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; 3485 foreach ( $html_atts as $attribute_name => $attribute_value ) { 3486 if ( in_array( $attribute_name, array( 'loop', 'autoplay', 'muted' ), true ) && true === $attribute_value ) { 3487 // Add boolean attributes without their value for true. 3488 $attr_strings[] = esc_attr( $attribute_name ); 3489 } elseif ( 'preload' === $attribute_name && ! empty( $attribute_value ) ) { 3490 // Handle the preload attribute with specific allowed values. 3491 $allowed_preload_values = array( 'none', 'metadata', 'auto' ); 3492 if ( in_array( $attribute_value, $allowed_preload_values, true ) ) { 3493 $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); 3494 } 3495 } elseif ( ! empty( $attribute_value ) ) { 3496 // For non-boolean attributes, add them with their value. 3497 $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); 3498 } 3487 3499 } 3488 3500 -
trunk/tests/phpunit/tests/media.php
r59473 r59954 1061 1061 'autoplay' => true, 1062 1062 'muted' => true, 1063 'preload' => true,1063 'preload' => 'metadata', 1064 1064 'width' => 123, 1065 1065 'height' => 456, … … 1070 1070 $this->assertStringContainsString( 'src="https://example.com/foo.mp4', $actual ); 1071 1071 $this->assertStringContainsString( 'poster="https://example.com/foo.png', $actual ); 1072 $this->assertStringContainsString( 'loop ="1"', $actual );1073 $this->assertStringContainsString( 'autoplay ="1"', $actual );1072 $this->assertStringContainsString( 'loop', $actual ); 1073 $this->assertStringContainsString( 'autoplay', $actual ); 1074 1074 $this->assertStringContainsString( 'muted', $actual ); 1075 $this->assertStringContainsString( 'preload=" 1"', $actual );1075 $this->assertStringContainsString( 'preload="metadata"', $actual ); 1076 1076 $this->assertStringContainsString( 'width="123"', $actual ); 1077 1077 $this->assertStringContainsString( 'height="456"', $actual ); -
trunk/tests/phpunit/tests/widgets/wpWidgetMediaVideo.php
r52248 r59954 278 278 // Custom attributes. 279 279 $this->assertStringContainsString( 'preload="metadata"', $output ); 280 $this->assertStringContainsString( 'loop ="1"', $output );280 $this->assertStringContainsString( 'loop', $output ); 281 281 282 282 // Externally hosted video.
Note: See TracChangeset
for help on using the changeset viewer.