in imagecache.module
function theme_imagecache($namespace, $path, $alt = '', $title = '', $attributes = null) {
// check is_null so people can intentionally pass an empty array of attributes to override
// the defaults completely... if
if (is_null($attributes)) {
$attributes['class'] = 'imagecache imagecache-'. $namespace;
}
$attributes = drupal_attributes($attributes);
$imagecache_url = imagecache_create_url($namespace, $path);
return '<img src="'. $imagecache_url .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
}
You can see that height and width are not set, while it is done for example in theme_imagefield_image() in imagefield.module
function theme_imagefield_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
$file = (array)$file;
if (!$getsize || (is_file($file['filepath']) && (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath'])))) {
$attributes = drupal_attributes($attributes);
$path = $file['fid'] == 'upload' ? $file['preview'] : $file['filepath'];
$alt = empty($alt) ? $file['alt'] : $alt;
$title = empty($title) ? $file['title'] : $title;
$url = $file['fid'] == 'upload' ? url($file['preview']) : file_create_url($path);
return '<img src="'. check_url($url) .'" alt="'.
check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
}
}
Comments
Comment #1
dman commentedWell,
I'd have expected that both of them should start using theme_image()
BUT
due to the way imagecache works - there is a chance that the image is not there until the browser goes looking for it. A little bit quantum that way ;-)
as such, it's possible that we don't know the dimensions at the time the page is built, so it was safer to say nothing.
But yeah, it would be tidy to pass through the sizes I guess. IF the file exists.
code from theme_image() above could be borrowed.
Comment #2
fizk commentedComment #3
j0rd commented#1047416: Width and height not set on theme_imagecache properly is where this issue currently lives.
Comment #4
fuzzy76 commented