In Drupal 5 there is a new incompatibility between image.module and img_assist.module.
ANALYSIS
In D4, the various sizes of images were defined by constant character strings: 'thumbnail', '_original' etc. In D5, these strings are defined constants (IMAGE_THUMBNAIL, IMAGE_ORIGINAL) with the customary values. In both releases, when an image node is added with an image file, the size constant string is stored in the filename column of the files table and passed around with the node in size['label'].
In D5, there are now translated strings describing the image size: t('Thumbnail'), t('Original') etc. When img_assist_ properties_form() generates a pop-up with a <select> for image size, it uses these strings, as returned by image_get_sizes().
When the pop-up input is submitted and passed to
img_assist_properties_form_validate(), the input values are passed to img_assist_render_image(), which uses the input NID to load data about the image node, including an images[] array whose keys are the values in the filename column of the files table selected by the NID. The image width and height selected in the pop-up are compared to the width and height of the image keyed by filename '_original'. If there is not an exact match, then image_get_sizes() is called to generate a list of 'standard' sizes from the defined constants (IMAGE_ORIGINAL, etc.) plus values in variable 'image_sizes', if any. Each element of the array returned by image_get_sizes() is an array containing the humanly-translated label of the size, in element 'label', and the dimensions of that size. Note that 'label => t('Thumbnail'), etc. Now the image dimensions requested in the pop-up are compared to these standard sizes, and if one matches closely enough, that image is selected by the value in 'label' - the translated string.
Now this label as passed as a size argument to theme_img_assist_inline(), which searches the files table for a file with filename exactly matching the size argument. Since 'thumbnail', for example, is not an exact match to 'Thumbnail' (let alone 'Thumbnail' translated into other languages), no matching file is found and no <img ... /> element is generated for the image.
FIX:
The fix is to modify img_assist.module to use the key rather than the label returned by image_get_sizes(). The attached patch does that, and also tracks the name change from _image_get_sizes() to image_get_sizes().
| Comment | File | Size | Author |
|---|---|---|---|
| img_assist_13.patch | 3.73 KB | dharmatech |
Comments
Comment #1
zoo33 commentedWow... I'm sorry you put all this effort into working on this, because it's already been fixed in this issue. :(
Please use the -dev version of this module until there is another release ready.
And for the record, those changes to the Image module happened in 5.x-1.3.
Comment #2
dharmatech commentedLooked everywhere I could think of for -dev version, finally gave up and just fixed the bug.
Could you perhaps indicate where there is a -dev version? Thanks
Comment #3
zoo33 commentedIf you look at this module's project page you'll see a section called Development Snapshots and there you'll find version 5.x-1.x-dev.