function theme_shadowbox_formatter in Shadowbox 7.3
Same name and namespace in other branches
- 8 shadowbox.module \theme_shadowbox_formatter()
- 7.4 shadowbox.module \theme_shadowbox_formatter()
Returns HTML for an image field formatter.
Parameters
$variables: An associative array containing:
- item: An array of image data.
- image_style: An optional image style.
- path: An array containing the link 'path' and link 'options'.
1 theme call to theme_shadowbox_formatter()
- shadowbox_field_formatter_view in ./
shadowbox.module - Implements hook_field_formatter_view().
File
- ./
shadowbox.module, line 507 - Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.
Code
function theme_shadowbox_formatter($variables) {
$item = $variables['item'];
$image = array(
'path' => $item['uri'],
'alt' => $item['alt'],
);
// Do not output an empty 'title' attribute.
if (drupal_strlen($item['title']) > 0) {
$image['title'] = $item['title'];
}
$image_style = $variables['image_style'];
if ($variables['itemid'] == 0 || isset($variables['compact']) && !$variables['compact']) {
if ($image_style) {
$image['style_name'] = $image_style;
$image['attributes'] = array(
'class' => 'image-' . $image_style,
);
$output = theme('image_style', $image);
}
else {
$output = theme('image', $image);
}
}
else {
$output = "";
}
$linked_style = $variables['image_link'];
if ($linked_style) {
$path = image_style_url($linked_style, $item['uri']);
}
else {
$path = $item['uri'];
}
$gallery_id = $variables['gallery'];
$rel = $gallery_id != '' ? "shadowbox[{$gallery_id}]" : 'shadowbox';
$link_attributes = array(
'rel' => $rel,
'title' => $variables['title'],
);
$options = array(
'attributes' => $link_attributes,
'html' => TRUE,
);
$output = l($output, file_create_url($path), $options);
$wrapper_classes = $gallery_id != '' ? "sb-image sb-gallery sb-gallery-{$gallery_id}" : 'sb-image sb-individual';
return '<div class="' . $wrapper_classes . '"' . ($variables['itemid'] == 0 || isset($variables['compact']) && !$variables['compact'] ? '' : 'style="display:none;') . '>' . $output . '</div>';
}