function theme_baguettebox_formatter in baguetteBox.js 7
Returns HTML for an baguettebox field formatter.
1 theme call to theme_baguettebox_formatter()
- baguettebox_field_formatter_view in ./
baguettebox.module - Implements hook_field_formatter_view().
File
- ./
baguettebox.module, line 160 - Primary hooks for baguettebox module.
Code
function theme_baguettebox_formatter($vars) {
$item = $vars['item'];
$image = array(
'path' => $item['uri'],
);
if (array_key_exists('alt', $item)) {
$image['alt'] = $item['alt'];
}
if (isset($item['attributes'])) {
$image['attributes'] = $item['attributes'];
}
if (isset($item['width']) && isset($item['height'])) {
$image['width'] = $item['width'];
$image['height'] = $item['height'];
}
// Do not output an empty 'title' attribute.
if (isset($item['title']) && drupal_strlen($item['title']) > 0) {
$image['title'] = $item['title'];
}
if ($vars['image_style']) {
$image['style_name'] = $vars['image_style'];
$output = theme('image_style', $image);
}
else {
$output = theme('image', $image);
}
$link_attributes = array();
if (isset($image['title'])) {
$link_attributes['data-caption'] = $item['title'];
}
elseif (isset($image['alt'])) {
$link_attributes['data-caption'] = $item['alt'];
}
return l($output, $vars['path'], array(
'html' => TRUE,
'attributes' => $link_attributes,
));
}