[wp-trac] [WordPress Trac] #17626: image_get_intermediate_size() may return wrong thumbnail size
WordPress Trac
noreply at wordpress.org
Sat Jan 3 17:29:25 UTC 2015
#17626: image_get_intermediate_size() may return wrong thumbnail size
--------------------------+-----------------------------
Reporter: chipbennett | Owner: markoheijnen
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future Release
Component: Media | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+-----------------------------
Comment (by joemcgill):
Replying to [comment:32 Krstarica]:
Thanks for the clarification.
In [attachment:17262.3.diff] I've added new unit tests for the cases you
bring up and they are currently passing with the changes to the function
as is.
To explain how this is working: when you add a custom image size with a
zero value like `add_image_size('my_size, 300, 0)`, an intermediate size
will be added to the attachment metadata for uploaded images with the
height and width attributes that have been calculated after it was
resized. For example, an image that is 600x400 will have an intermediate
size with an array that looks like this:
{{{
["my_size"]
array(4) {
["file"]=>
string(19) "filename.jpg"
["width"]=>
int(300)
["height"]=>
int(200)
["mime-type"]=>
string(10) "image/jpeg"
}
}}}
So, calling `image_get_intermediate_size()` with a zero value will never
find an exact match, but will instead need to find the closest crop, which
it now seems to be doing correctly. If possible, I would suggest actually
passing the name of the custom crop, like
`image_get_intermediate_size('my_size')`.
Let me know if this answers your question.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/17626#comment:33>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list