theme_imagecache

5 imagecache.module theme_imagecache($namespace, $path, $alt = '', $title = '', $attributes = null)
6 imagecache.module theme_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $absolute = TRUE)

Create and image tag for an imagecache derivative

Parameters

$presetname: String with the name of the preset used to generate the derivative image.

$path: String path to the original image you wish to create a derivative image tag for.

$alt: Optional string with alternate text for the img element.

$title: Optional string with title for the img element.

$attributes: Optional drupal_attributes() array. If $attributes is an array then the default imagecache classes will not be set automatically, you must do this manually.

$getsize: If set to TRUE, the image's dimension are fetched and added as width/height attributes.

$absolute: A Boolean indicating that the URL should be absolute. Defaults to TRUE.

Return value

HTML img element string.

1 string reference to 'theme_imagecache'

39 theme calls to theme_imagecache()

File

contributions/imagecache/imagecache.module, line 887
Dynamic image resizer and image cacher.

Code

function theme_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $absolute = TRUE) {
  // Check is_null() so people can intentionally pass an empty array of
  // to override the defaults completely.
  if (is_null($attributes)) {
    $attributes = array('class' => 'imagecache imagecache-' . $presetname);
  }
  $ours = array(
    'src' => imagecache_create_url($presetname, $path, FALSE, $absolute), 
    'alt' => $alt, 
    'title' => $title,
  );
  if ($getsize && ($image = image_get_info(imagecache_create_path($presetname, $path)))) {
    $ours += array(
      'width' => $image['width'],
      'height' => $image['height'],
    );
  }

  return '<img' . drupal_attributes($ours + $attributes) . '/>';
}