You are here

function theme_photoswipe_formatter_imagefield in PhotoSwipe 6

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_photoswipe_formatter_imagefield'
photoswipe_theme in ./photoswipe.module
Implementation of hook_theme().

File

./photoswipe.module, line 381

Code

function theme_photoswipe_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 'photoswipe':
      $gallery_id = 'simple';
      break;
    case 'photoswipe_field':
      $gallery_id = $field_name;
      break;
    case 'photoswipe_nid':
      $gallery_id = "nid-{$element['#node']->nid}";
      break;
  }
  $presets = photoswipe_get_imagecache_presets();
  foreach ($presets as $preset) {
    $presets[] = $preset['presetname'];
  }
  if ($source == 'original' || in_array($source, $presets)) {
    $output = theme('imagefield_image_imagecache_photoswipe', $source, $destination, $item, $gallery_id, $field_type_names);
  }
  return $output;
}