diff --git src/wp-includes/media.php src/wp-includes/media.php
index 17af247..1d4a3f2 100644
|
|
function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa |
818 | 818 | if ( is_array( $image_meta ) ) { |
819 | 819 | $size_array = array( absint( $width ), absint( $height ) ); |
820 | 820 | $sources = wp_calculate_image_srcset( $src, $size_array, $image_meta, $attachment_id ); |
821 | | $sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $attachment_id ); |
| 821 | $sizes = wp_get_attachment_image_sizes( $size, $image_meta, $attachment_id ); |
822 | 822 | |
823 | 823 | if ( count( $sources ) > 1 && ( $sizes || ! empty( $attr['sizes'] ) ) ) { |
824 | 824 | $attr['srcset'] = wp_image_srcset_attr( $sources, $size_array, $image_meta, $attachment_id ); |
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index 3a71bd2..5a51c8b 100644
|
|
EOF; |
926 | 926 | /** |
927 | 927 | * @ticket 33641 |
928 | 928 | */ |
| 929 | function test_wp_get_attachment_image_with_sizes_named_filter() { |
| 930 | add_filter( 'wp_get_attachment_image_sizes', array( $this, '_filter_attachment_image_sizes_named_size' ), 10, 4 ); |
| 931 | |
| 932 | $image = wp_get_attachment_image( self::$large_id, 'large' ); |
| 933 | $srcset = '(max-width: 600px) 80vw, 600px'; |
| 934 | |
| 935 | $this->assertTrue( strrpos( $image, $srcset ) > 0 ); |
| 936 | |
| 937 | //cleanup |
| 938 | remove_filter( 'wp_get_attachment_image_sizes', array( $this, '_filter_attachment_image_sizes_named_size' ) ); |
| 939 | } |
| 940 | |
| 941 | // Example filter |
| 942 | function _filter_attachment_image_sizes_named_size( $sizes, $size, $image_meta, $attachment_id ) { |
| 943 | if ( $size === 'large' ) { |
| 944 | $sizes = '(max-width: 600px) 80vw, 600px'; |
| 945 | } |
| 946 | |
| 947 | return $sizes; |
| 948 | } |
| 949 | |
| 950 | /** |
| 951 | * @ticket 33641 |
| 952 | */ |
929 | 953 | function test_wp_make_content_images_responsive() { |
930 | 954 | $image_meta = wp_get_attachment_metadata( self::$large_id ); |
931 | 955 | $size_array = $this->_get_image_size_array_from_name( 'medium' ); |