You are here

function theme_imagecache in ImageCache 6.2

Same name and namespace in other branches
  1. 5.2 imagecache.module \theme_imagecache()
  2. 5 imagecache.module \theme_imagecache()

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.

4 theme calls to theme_imagecache()
theme_imagecache_formatter_default in ./imagecache.module
theme_imagecache_formatter_imagelink in ./imagecache.module
theme_imagecache_formatter_linked in ./imagecache.module
theme_imagecache_imagelink in ./imagecache.module
Create a link the original image that wraps the derivative image.

File

./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) . '/>';
}