function theme_picture_formatter_colorbox in Picture 7.2
Same name and namespace in other branches
- 7 picture.module \theme_picture_formatter_colorbox()
Theme function to add support for colorbox.
1 theme call to theme_picture_formatter_colorbox()
- template_preprocess_flexslider_picture_list in flexslider_picture/
theme/ flexslider_picture.theme.inc - Process the items and prepare the item slides to be rendered.
File
- ./
picture.module, line 1289 - Picture formatter.
Code
function theme_picture_formatter_colorbox($variables) {
if (!isset($variables['breakpoints']) || empty($variables['breakpoints'])) {
return theme('image_formatter', $variables);
}
$item = $variables['item'];
// Do not output an empty 'title' attribute.
if (isset($item['title']) && drupal_strlen($item['title']) == 0) {
unset($item['title']);
}
$item['style_name'] = $variables['image_style'];
$item['breakpoints'] = $variables['breakpoints'];
if (!isset($item['path']) && isset($variables['uri'])) {
$item['path'] = $variables['uri'];
}
$output = theme('picture', $item);
// If an error happened skip further processing.
if (empty($output)) {
return $output;
}
if (isset($variables['colorbox_group'])) {
$item['breakpoints'] = $variables['colorbox_group'];
$item['style_name'] = $variables['colorbox_image_style'];
$id = 'picture-colorbox-' . user_password();
$colorbox = '<div style="display: none;"><div id="' . $id . '" class="picture-colorbox-container">' . theme('picture', $item) . '</div></div>';
$options = array(
'attributes' => array(
'class' => array(
'colorbox-inline',
),
),
'query' => array(
'maxWidth' => '80%',
'maxHeight' => '80%',
'inline' => 'true',
),
'fragment' => $id,
'html' => TRUE,
);
if (!empty($variables['colorbox_group_id'])) {
$options['attributes']['rel'] = $variables['colorbox_group_id'];
}
if (!empty($variables['colorbox_caption'])) {
$options['query']['title'] = $variables['colorbox_caption'];
}
// Do not load picture automatically.
$colorbox = str_replace('<picture', '<span lazyload="lazyload"', $colorbox);
$colorbox = str_replace('</picture>', '</span>', $colorbox);
$colorbox = str_replace(' srcset="', ' data-srcset="', $colorbox);
$output = l($output, current_path(), $options) . $colorbox;
}
return $output;
}