In theme_imagecache()

function theme_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
  if ($image = image_get_info(imagecache_create_path($namespace, $path))) {
    $attributes['width'] = $image['width'];
    $attributes['height'] = $image['height'];
  }
  // 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;
  }
...

The default classes are only added if $attributes is null, however, that will never be true if the image_get_info() call succeeds because it then defines width and height attributes. This causes the default classes to be added sometimes but not other depeding on the image_get_info() call.

The classes section should be moved to the top like this to achieve the correct functionality:

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;
  }
  if ($image = image_get_info(imagecache_create_path($namespace, $path))) {
    $attributes['width'] = $image['width'];
    $attributes['height'] = $image['height'];
  }

Comments

drewish’s picture

Version: 6.x-2.0-beta8 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.37 KB
drewish’s picture

StatusFileSize
new3.66 KB

rolling in some adjacent PHPDoc and variable name fixes.

drewish’s picture

Status: Needs review » Fixed

committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.