You appear to be a bot. Output may be restricted
Description
Usage
Tests_Media::test_wp_get_attachment_image_srcset();
Parameters
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/media.php
Lines:
1 to 36 of 36
function test_wp_get_attachment_image_srcset() { $_wp_additional_image_sizes = wp_get_additional_image_sizes(); $image_meta = wp_get_attachment_metadata( self::$large_id ); $size_array = array( 1600, 1200 ); // full size $srcset = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta ); $year_month = gmdate( 'Y/m' ); $uploads_dir = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/'; // Set up test cases for all expected size names. $intermediates = array( 'medium', 'medium_large', 'large', 'full' ); foreach ( $_wp_additional_image_sizes as $name => $additional_size ) { if ( ! $_wp_additional_image_sizes[ $name ]['crop'] || 0 === $_wp_additional_image_sizes[ $name ]['height'] ) { $intermediates[] = $name; } } $expected = ''; foreach ( $image_meta['sizes'] as $name => $size ) { // Whitelist the sizes that should be included so we pick up 'medium_large' in 4.4. if ( in_array( $name, $intermediates, true ) ) { $expected .= $uploads_dir . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, '; } } $expected .= $uploads_dir . $image_meta['file'] . ' ' . $image_meta['width'] . 'w'; $expected_srcset = $this->_src_first( $expected, $uploads_dir . $image_meta['file'], $size_array[0] ); $this->assertSame( $expected_srcset, $srcset ); }