diff --git src/wp-includes/media.php src/wp-includes/media.php
index 0ba67a9..405a989 100644
|
|
|
function wp_calculate_image_srcset( $image_name, $size_array, $image_meta, $atta |
| 972 | 972 | return false; |
| 973 | 973 | } |
| 974 | 974 | |
| | 975 | // Don't add srcset attributes to animated gifs. See #28474. |
| | 976 | if ( 'image/gif' === $image_sizes['thumbnail']['mime-type'] && false !== strpos( $image_name, $image_meta['file'] ) ) { |
| | 977 | return false; |
| | 978 | } |
| | 979 | |
| 975 | 980 | // Add full size to the '$image_sizes' array. |
| 976 | 981 | $image_sizes['full'] = array( |
| 977 | 982 | 'width' => $image_meta['width'], |
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index aa6cab4..81442b6 100644
|
|
|
EOF; |
| 949 | 949 | // The content filter should return the image unchanged. |
| 950 | 950 | $this->assertSame( $image_html, wp_make_content_images_responsive( $image_html ) ); |
| 951 | 951 | } |
| | 952 | |
| | 953 | /** |
| | 954 | * @ticket 33641 |
| | 955 | * @ticket 34528 |
| | 956 | */ |
| | 957 | function test_wp_calculate_image_srcset_animated_gifs() { |
| | 958 | // Mock meta for an animated gif. |
| | 959 | $image_meta = array( |
| | 960 | 'width' => 1200, |
| | 961 | 'height' => 600, |
| | 962 | 'file' => 'animated.gif', |
| | 963 | 'sizes' => array( |
| | 964 | 'thumbnail' => array( |
| | 965 | 'file' => 'animated-150x150.gif', |
| | 966 | 'width' => 150, |
| | 967 | 'height' => 150, |
| | 968 | 'mime-type' => 'image/gif' |
| | 969 | ), |
| | 970 | 'medium' => array( |
| | 971 | 'file' => 'animated-300x150.gif', |
| | 972 | 'width' => 300, |
| | 973 | 'height' => 150, |
| | 974 | 'mime-type' => 'image/gif' |
| | 975 | ), |
| | 976 | 'large' => array( |
| | 977 | 'file' => 'animated-1024x512.gif', |
| | 978 | 'width' => 1024, |
| | 979 | 'height' => 512, |
| | 980 | 'mime-type' => 'image/gif' |
| | 981 | ), |
| | 982 | ) |
| | 983 | ); |
| | 984 | |
| | 985 | $image_name = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file']; |
| | 986 | // Test with soft resized size array. |
| | 987 | $size_array = array(900, 450); |
| | 988 | |
| | 989 | $this->assertFalse( wp_calculate_image_srcset( $image_name, $size_array, $image_meta ) ); |
| | 990 | } |
| 952 | 991 | } |