[wp-trac] [WordPress Trac] #17626: image_get_intermediate_size() may return wrong thumbnail size
WordPress Trac
wp-trac at lists.automattic.com
Tue May 31 14:33:27 UTC 2011
#17626: image_get_intermediate_size() may return wrong thumbnail size
--------------------------+-----------------------------
Reporter: chipbennett | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Keywords: has-patch
--------------------------+-----------------------------
See [http://wordpress.stackexchange.com/questions/17511/featured-image-
with-the-same-height-thumbs-returns-wrong-thumb this WPSE question] for a
more detailed explanation of the problem.
Essentially, if `get_the_post_thumbnail()` is passed an array for the
`$size` argument, and if two images have one dimension exactly the same,
the image with the ''smaller'' opposing dimension will be returned, even
if the dimensions for the other image are declared explicitly.
The issue appears to be due to the way that
`image_get_intermediate_size()` determines if an image exists that is
cropped to dimensions similar to the specified `$size` array. As soon as
it finds one, it uses it.
I've attached a patch that first attempts to find an image cropped
''exactly'' on both dimensions, before looking for images cropped exactly
only on one dimension. There will still be edge cases where the wrong
image might be returned, but I'm not sure of the most efficient way to
handle such cases.
(Note: props to Rarst for finding the underlying issue.)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17626>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list