function shadowbox_field_formatter_view in Shadowbox 7.3
Implements hook_field_formatter_view().
File
- ./
shadowbox.module, line 437 - Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.
Code
function shadowbox_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
$shadowbox_enabled_path = _shadowbox_activation() && variable_get('shadowbox_enabled', TRUE);
switch ($display['settings']['gallery']) {
case 'page':
$gallery_id = 'gallery';
break;
case 'field':
$gallery_id = $field['field_name'];
break;
case 'nid':
$info = entity_get_info($entity_type);
$id = $info['entity keys']['id'];
$gallery_id = "{$entity_type}-{$entity->{$id}}";
break;
default:
$gallery_id = "";
break;
}
foreach ($items as $delta => $item) {
switch ($display['settings']['title']) {
case 'alt':
$title = $item['alt'];
break;
case 'title':
$title = $item['title'];
break;
case 'node':
$title = $entity->title;
break;
default:
$title = '';
break;
}
$element[$delta] = array(
'#theme' => 'shadowbox_formatter',
'#itemid' => $delta,
'#item' => $item,
'#image_style' => $display['settings']['image_style'],
'#image_link' => $display['settings']['image_link'],
'#gallery' => $gallery_id,
'#compact' => $display['settings']['compact'],
'#title' => $title,
);
if ($shadowbox_enabled_path) {
$element[$delta]['#attached']['library'][] = array(
'shadowbox',
'shadowbox',
);
}
}
return $element;
}