You appear to be a bot. Output may be restricted
Description
Tests if wp_get_attachment_image() uses wp_get_attachment_metadata().
In this way, the meta data can be filtered using the filter `wp_get_attachment_metadata`. The test checks if the image size that is added in the filter is used in the output of `wp_get_attachment_image()`.
Usage
Tests_Media::test_wp_get_attachment_image_should_use_wp_get_attachment_metadata();
Parameters
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/media.php
Lines:
1 to 20 of 20
function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() { add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 ); remove_all_filters( 'wp_calculate_image_sizes' ); $actual = wp_get_attachment_image( self::$large_id, 'testsize' ); $year = gmdate( 'Y' ); $month = gmdate( 'm' ); $expected = '<img width="999" height="999" src="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year . '/' . $month . '/test-image-testsize-999x999.png"' . ' class="attachment-testsize size-testsize" alt=""' . ' srcset="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year . '/' . $month . '/test-image-testsize-999x999.png 999w,' . ' http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year . '/' . $month . '/test-image-large-150x150.png 150w"' . ' sizes="(max-width: 999px) 100vw, 999px" />'; remove_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ) ); $this->assertSame( $expected, $actual ); }