You are here

function theme_shadowbox_formatter_imagefield in Shadowbox 6.4

Same name and namespace in other branches
  1. 6.2 shadowbox.module \theme_shadowbox_formatter_imagefield()
  2. 6.3 shadowbox.module \theme_shadowbox_formatter_imagefield()

Implementation of theme_shadowbox_formatter_imagefield().

Note: Fields with multiple values are processed during a single invocation of this function.

1 string reference to 'theme_shadowbox_formatter_imagefield'
shadowbox_theme in ./shadowbox.module
Implementation of hook_theme().

File

./shadowbox.module, line 294
Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.

Code

function theme_shadowbox_formatter_imagefield($element) {
  if (!module_exists('imagefield') || !module_exists('imagecache')) {
    return;
  }
  $field_name = $element['#field_name'];
  $field_type_names = $element['#type_name'] . '_' . $field_name;
  $item = $element['#item'];
  $formatter = $element['#formatter'];
  $node = node_load($element['#node']->nid);
  list($theme, $source, $destination) = explode('___', $formatter, 3);
  switch ($theme) {
    case 'shadowbox_gallery':
      $gallery_id = 'gallery';
      break;
    case 'shadowbox_gallery_field':
      $gallery_id = $field_name;
      break;
    case 'shadowbox_gallery_nid':
      $gallery_id = "nid-{$element['#node']->nid}";
      break;
  }
  $presets = shadowbox_get_imagecache_presets();
  foreach ($presets as $preset) {
    $presets[] = $preset['presetname'];
  }
  if ($source == 'original' || in_array($source, $presets)) {
    $output = theme('imagefield_image_imagecache_shadowbox', $source, $destination, $item, $gallery_id, $field_type_names);
  }
  return $output;
}