Sorry if this is a duplicate. I see several issues that are similar, but not precisely what I am experiencing.
I configured the image module with 6 image sizes that just specify the width, not the height:
Original: - x -
Thumbnail: 100 x -
Preview: 480 x -
Half-Width: 240 x -
Third-Width: 160 x -
Gallery: 100 x -
I have also turned off all the "Image derivatives" options.
When only one dimension is specified, img_assist macros (which call img_assist_render_image) effectively ignore all possible sizes and always choose the smallest one, in this case, "Thumbnail."
Here is a patch against 5.x-1.8, which fixes the problem by passing the image's aspect ratio to images_get_size to force it to return both width and height. I haven't looked at all the other branches, but I think the same problem and same patch work everywhere else.
diff -u -r1.68.2.54 img_assist.module
--- img_assist.module 15 Jul 2009 22:58:26 -0000 1.68.2.54
+++ img_assist.module 21 Jul 2009 16:18:00 -0000
@@ -1298,7 +1298,7 @@
$diag_size_new = sqrt(pow($width, 2) + pow($height, 2));
$closest_difference = 9999;
- foreach (image_get_sizes() as $key => $stdsize) {
+ foreach (image_get_sizes(NULL, $aspect_ratio) as $key => $stdsize) {
$width_std = $stdsize['width'];
$height_std = $stdsize['height'];
// Get default width and height, taking the aspect ratio into account.
| Comment | File | Size | Author |
|---|---|---|---|
| img_assist-5.x-1.8.patch | 614 bytes | therzog |
Comments
Comment #1
jpsalter commentedThis also works for: img_assist.module,v 1.72.2.7 2009/07/15 22:58:12 aka (6.x-1.1)
Comment #2
jpsalter commentedPatch does not work for: 6.x-3.x-dev. Even when I edit the image_get_sizes() function. It looks like the algorithm for choosing the closes preset image size fails when only a single image dimension is given.
The simple work around is to allow "create custom size inline images" on the admin/settings/img_assist page.
Comment #3
sun5.x-1.x is too old and won't get any bugfixes besides security issues.
Aside from that, I think this is a duplicate of #293909-31: Always adds thumbnail only (unspecified image preset width or height), which has been committed recently.