You are here

function theme_link_image_formatter_imagecache_default in Link Image Formatter 6

Theme function for 'image' link imagecache field formatter.

1 string reference to 'theme_link_image_formatter_imagecache_default'
link_image_theme in ./link_image.module
Implements hook_theme().
2 theme calls to theme_link_image_formatter_imagecache_default()
theme_link_image_formatter_imagecache_imagelink in ./link_image.theme.inc
Theme function for 'image' link imagecache field formatter linked to image.
theme_link_image_formatter_imagecache_linked in ./link_image.theme.inc
Theme function for 'image' link imagecache field formatter linked to node.

File

./link_image.theme.inc, line 77

Code

function theme_link_image_formatter_imagecache_default($element, $append_class = TRUE) {
  $item = $element['#item'];
  if (!module_exists('imagecache_external') || empty($item['url'])) {
    return;
  }
  $style = 'default';

  // Extract the preset name from the formatter name.
  $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_imagecache'));
  $title = isset($item['display_title']) ? $item['display_title'] : NULL;
  $class = '';
  if ($append_class) {
    $class = "link-image link-image-{$style} link-image-{$element['#formatter']}";
  }
  $path = imagecache_external_generate_path($item['url'], $presetname);
  if ($path) {
    $path = substr($path, strlen(base_path()));
    return theme('image', $path, $title, $title, array(
      'class' => $class,
    ), FALSE);
  }
  else {
    return '';
  }
}