attributes: string/array
pz - May 10, 2005 - 21:13
| Project: | Image |
| Component: | image.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Robrecht Jacques |
| Status: | closed |
Description
It looks like the function image_display calls theme('image', ...) with attributes as a string, but the function theme_image expects attributes to be in array format which gives errors (warnings),
warning: Invalid argument supplied for foreach()
(I am not really sure if my testinstallation is using latest version of everything so if noone else has this problem this is probably because I havent updated them, will try to update in a day or to and recheck this.)

#1
Upgraded to priority normal.
There seems to be something wrong with drupals upload function now so I can't upload patch, so here is a manual fix
$attr = array('width' => $info['width'], 'height' => $info['height']) + $attributes;should replace line 346 which was previously
$attr = 'width="'.$info['width'].'" height="'.$info['height'].'" ' . drupal_attributes($attributes);#2
Patch
#3
theme_image has now changed back, so this patch should not be applied.
#4
Should probably be applied against cvs but not 4.6
#5
#6
is this still an issue? doesn't look like it to me...
closing.
#7
If I read the files correctly, the cvs version the function theme_image in file includes/theme.inc has changed and now wants an array instead of a string. For the 4.6.0 branch it wants a string and this patch should not be applied.
I am setting this to patch again for cvs, feel free to close it again if I have misunderstood anything.
#8
I can confirm this is still an issue in CVS:
<span class="image preview"><img src="http://localhost/~robrechtj/drupal-cvs/files/images/06_13_0.jpg" alt="a test image" title="a test image" /></span>widthorheightattribute is set!<span class="image preview"><img src="http://localhost/~robrechtj/drupal-cvs/files/images/06_13_0.jpg" alt="a test image" title="a test image" width="640" height="480"/></span>widthandheightare presentThe reason is that in CVS "theme_image' now runs a 'drupal_attributes' on the 'attr' parameter. This parameter has changed from a string to an array in revision 1.235 of "theme.inc".
So, this patch NEEDS to be applied to CVS. And it SHOULD NOT be applied to 4-6.
#9
Patch ready to be committed.
One more thing:
drupal_attributesreturns an empty string if$attris not an array, that is why thewidthandheight"disappear".#10
committed, thanks!
#11
#12
#13
#14
#15