[drupal-devel] [bug] theme_image() doesn't actually output width and height of image

Robrecht Jacques drupal-devel at drupal.org
Mon Sep 12 21:51:13 UTC 2005


Issue status update for 
http://drupal.org/node/30935
Post a follow up: 
http://drupal.org/project/comments/add/30935

 Project:      Drupal
 Version:      cvs
 Component:    theme system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  m3avrck
 Updated by:   Robrecht Jacques
 Status:       patch (ready to be committed)

This is correct, the theme('image') for the screenshots need to have
TRUE as last parameter, or omit the parameter (like the patch does).
This last patch is ok. Didn't test it, but I'm sure it is correct.
Without the width and height is will work too (it has before), but this
is cleaner HTML.


Patch is ready to commit.




Robrecht Jacques



Previous comments:
------------------------------------------------------------------------

Sun, 11 Sep 2005 16:22:28 +0000 : m3avrck

Function theme_image() doesn't actually return a width and height for an
image like it claims to do.




------------------------------------------------------------------------

Sun, 11 Sep 2005 19:30:35 +0000 : m3avrck

Attachment: http://drupal.org/files/issues/drupal_11.patch (2.74 KB)

Ok patched attached, which fixes this issue. Also, included a patch for
system.module which sets the screen shots to 'TRUE' so image dimensions
will also be outputted there as well (which they should be!).




------------------------------------------------------------------------

Sun, 11 Sep 2005 19:33:41 +0000 : m3avrck

Attachment: http://drupal.org/files/issues/drupal_12.patch (2.75 KB)

Fixed a tab issue.




------------------------------------------------------------------------

Sun, 11 Sep 2005 19:35:46 +0000 : m3avrck

Attachment: http://drupal.org/files/issues/drupal_13.patch (2.75 KB)

Fixed a spacing issue.




------------------------------------------------------------------------

Mon, 12 Sep 2005 14:18:32 +0000 : Souvent22

Used the patch, and did a quick test. Worked well for me. +1.




------------------------------------------------------------------------

Mon, 12 Sep 2005 16:21:16 +0000 : Robrecht Jacques

I don't see why this patch is needed, "theme_image" returns a img tag
with the width and height set if $getsize = TRUE.
Eg:
$node->body = theme('image', file_create_path('druplicon.png'), 'no
alt', 'no title', array(), TRUE) .
              theme('image',
file_create_path('druplicon.png'), 'no alt', 'no title', array(),
FALSE)
will return:
<img src="files/druplicon.png" alt="no alt" title="no title" width="88"
height="100" />
<img src="files/druplicon.png" alt="no alt" title="no title"  />
(if druplicon.png is copied to the files/ directory).


I don't see what you are fixing...


You are right about the use of theme('image') in system.module though.
The "false" should be "true".




------------------------------------------------------------------------

Mon, 12 Sep 2005 16:40:56 +0000 : m3avrck

Well the actual code in theme_image() returned this:


return '<img src="'. check_url($path) .'" alt="'. check_plain($alt) .'"
title="'. check_plain($title) .'" '. $image_attributes . $attributes
.'/>';


There is *no* mention of the $width and $height variables that are
assigned above, not used at all. I checked images in the themes
directory and none had this information, unless I was missing something
obvious, I see no way that is being generated... nothing in the above
img src about it.




------------------------------------------------------------------------

Mon, 12 Sep 2005 18:41:25 +0000 : Dries

Taken from http://php.net/getimagesize: "Index 3 is a text string with
the correct height="yyy" width="xxx" string that can be used directly
in an IMG tag.".  $image_attributes contains this information.  Marking
this fixed.  Please reopen if not.




------------------------------------------------------------------------

Mon, 12 Sep 2005 18:49:33 +0000 : m3avrck

Attachment: http://drupal.org/files/issues/system.module_10.patch (1.53 KB)

Dries, great catch! What prompted this originally was that the
screenshots on the theme page didn't have dimensions, didn't realize
that index [3] returned this. Anyways, this patch fixes the screen
shots and adds widths/heights.







More information about the drupal-devel mailing list