In the function _image_get_sizes(), the optional first parameter $size should be a string indicating which image size to return. For example, "thumbnail"
However, the array of image sizes is keyed incorrectly, so this param is effectively ignored. Currently line 891 has:
$sizes[$key] = $val;
..when the correct code should be:
$sizes[$val['label']] = $val;
| Comment | File | Size | Author |
|---|---|---|---|
| image_28.patch | 68.39 KB | drumdance |
Comments
Comment #1
drewish commenteda) your patch is broken. you've got some kind of a line ending issue that's causing it to do a delete/add of the entire file, it's even harder to review than if you'd just posted the module.
b) that's by design. it changed in the 1.2 release. it probably should have been a 2.x release but other modules have adopted the change so i'm not going to back it out now.
Comment #2
drumdance commentedSorry, that patch should not have been submitted at all. I'm having problems with diff and shouldn't have attached that file.
I'm not sure I follow how that code will work. The constants at the top are defined as strings, e.g.
And those same constants are used as defaults in this same function starting on line 871. As it currently stands, the function will never return correct dimensions if you use something like _image_get_sizes('thumbnail') or _image_get_sizes('preview') because it uses the array's key to decide what to return. The array's keys are all integers, so it will never return anything except the $defaults array.
If this is by design, what function should I use to get an image's size when using the constants defined at the top? I need this for some advanced theming stuff.
Looking further, it looks like this function won't work with line 313:
...because it uses a string for the first param while the function expects an integer.
Comment #3
drewish commentedit sounds like you either didn't run the update.php script or the updates failed. please try (re)running the image module's updates from #2.
Comment #4
drewish commentedi didn't make that very clear. run update.php and select update #2 for the image module.
Comment #5
drumdance commentedI ran update 2 and it didn't seem to make a difference. Maybe I'm misunderstanding. What function should I use to dynamically get the correct sizes for 'thumbnail', 'preview' etc?
Comment #6
drewish commentedyou shouldn't have numeric keys for the sizes array. that's what the update was supposed to fix. they should be strings... like the values defined by the IMAGE_ORIGINAL, IMAGE_PREVIEW, IMAGE_THUMBNAIL constants. you might just want to try resetting your sizes to the defaults. it'll mean rebuilding your thumbnails but hopefully it'll straighten out your sizes variable.