Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anton-vlasenko/60ac04daf8d8c0bcd378501efbf7bfb9 to your computer and use it in GitHub Desktop.
Save anton-vlasenko/60ac04daf8d8c0bcd378501efbf7bfb9 to your computer and use it in GitHub Desktop.
Trac Test Report Template
== Test Report
Testing Environment:
* Browser: Safari 15.4
* Theme: Twenty Twenty-Two
* Server: macOS 12.3, PHP 8.0.18 (native), Apache 2.4.53 (native)
* WordPress: 6.0-alpha-52448-src
TL;DR
I can't reproduce this bug.
The width of the image is limited by the value of the `$content_width` global variable.
There is no bug in the `wp_get_attachment_image_src` function.
More info can be found here: https://codex.wordpress.org/Content_Width
== Steps to test
1. Activate `Twenty Twenty-Two` theme.
2. Go to the `src/wp-content/themes/twentytwentytwo/functions.php` file and add the following code to the very end of the file:
{{{
global $content_width;
$content_width = 2000;
add_action( 'after_setup_theme', function() {
add_image_size( 'featured-home', 1600, 600, true );
} );
}}}
3. Go to the Media Library and upload a test image that's exactly `1600` x `600` in size.
4. Go to the database and check the last ID in the `posts` (`wp_posts`) table.
5. Add the following code to the very end of the `src/wp-content/themes/twentytwentytwo/functions.php` file (don't forget to replace the ID):
{{{
$image = wp_get_attachment_image_src( 'replace this value with ID of the last post', 'featured-home' );
}}}
6. Check the contents of the `$image` array (either with [https://www.php.net/manual/en/function.print-r.php print_r] or XDebug).
=== Actual result:
[[Image(https://cldup.com/_jxDZKLgee.png)]]
=== Expected result:
It should return an image that is 1600 x 600 in size.
That's exactly what's happening here, meaning there is no bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment