[wp-trac] [WordPress Trac] #29370: wp_get_attachment_image() returning unexpected image size
WordPress Trac
noreply at wordpress.org
Mon Aug 25 18:40:17 UTC 2014
#29370: wp_get_attachment_image() returning unexpected image size
---------------------------+-----------------------------
Reporter: martinleopold | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.9.2
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
I have a 'thumbnail' size image of 150x150 px and a 'thumb-250' size image
of 166x250 px.
{{{
add_image_size('thumb-250', 0, 250, false);
}}}
I am using wp_get_attachment_image() to get the best image fit for a
133x200 format.
{{{
wp_get_attachment_image( $id, array(133,200) );
}}}
this returns the 'thumbnail' size which has an area that's smaller than
the requested size, as well as a different aspect ratio. I would expect
the 'thumb-250' size image to be returned, which has a bigger area and the
exact aspect ratio that was requested.
I tracked this down to the first condition in the following line:
https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-
includes/media.php#L599
Why is the 'thumbnail' image size preferred in the selection process? This
means the thumbnail is always returned if it's next in row even if it's
area is smaller and the aspect ratio is off.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29370>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list