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

pz - May 15, 2005 - 22:13
Priority:minor» normal

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

pz - May 17, 2005 - 19:56

Patch

AttachmentSizeStatusTest resultOperations
image_4.patch994 bytesIgnoredNoneNone

#3

pz - May 17, 2005 - 20:49

theme_image has now changed back, so this patch should not be applied.

#4

pz - May 21, 2005 - 20:29
Version:4.6.x-1.x-dev» <none>

Should probably be applied against cvs but not 4.6

#5

pz - May 21, 2005 - 21:41

#6

walkah - May 28, 2005 - 03:37

is this still an issue? doesn't look like it to me...

closing.

#7

pz - May 28, 2005 - 07:35

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

Robrecht Jacques - August 2, 2005 - 21:14

I can confirm this is still an issue in CVS:

  • clean install of drupal and image
  • add an image
  • the source says: <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>
  • notice that no width or height attribute is set!
  • patching it (updated patch attached), gives: <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>
  • note that the width and height are present

The 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.

AttachmentSizeStatusTest resultOperations
image-cvs-22533.patch808 bytesIgnoredNoneNone

#9

Robrecht Jacques - August 2, 2005 - 21:16
Assigned to:Anonymous» Robrecht Jacques
Status:needs review» reviewed & tested by the community

Patch ready to be committed.

One more thing: drupal_attributes returns an empty string if $attr is not an array, that is why the width and height "disappear".

#10

walkah - August 3, 2005 - 00:44
Status:reviewed & tested by the community» fixed

committed, thanks!

#11

Anonymous - August 17, 2005 - 01:00

#12

Tobias Maier - August 31, 2005 - 01:04

#13

Anonymous - September 14, 2005 - 01:26

#14

Anonymous - September 28, 2005 - 07:01

#15

Anonymous - October 12, 2005 - 07:20
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.