function theme_media_gallery_block_thumbnail in Media Gallery 7
Same name and namespace in other branches
- 7.2 media_gallery.theme.inc \theme_media_gallery_block_thumbnail()
Displays a media item (entity) as a thumbnail in a block
1 theme call to theme_media_gallery_block_thumbnail()
- theme_media_gallery_collection_thumbnail in ./
media_gallery.theme.inc - Displays a media item (entity) as a thumbnail on a Gallery collection page
File
- ./
media_gallery.theme.inc, line 360 - Media Gallery Theming
Code
function theme_media_gallery_block_thumbnail($variables) {
$element = $variables['element'];
// Attach the colorbox javascript if the format calls for it.
$format = $element['#media_gallery_entity']->media_gallery_format[LANGUAGE_NONE][0]['value'];
$lightbox = is_numeric(strpos($format, 'lightbox')) ? TRUE : FALSE;
if ($lightbox) {
$element['file']['#attached']['js'][] = drupal_get_path('module', 'media_gallery') . '/colorbox-display.js';
$element['file']['#attached']['library'][] = array(
'media_gallery',
'colorbox',
);
}
// Get the rendered file without annoying DIV wrappers.
$element['file'] = array(
'#theme' => 'media_gallery_file_field_inline',
'0' => $element['file'],
);
$image = drupal_render($element['file']);
// Create some variables to be added to the main image link
$classes = $lightbox ? array(
'media-gallery-thumb',
'cbEnabled',
) : array(
'media-gallery-thumb',
);
$gallery_id = $element['#media_gallery_entity']->nid;
$media_id = $element['#file']->fid;
$link_path = "media-gallery/detail/{$gallery_id}/{$media_id}";
// Create a wrapper
$output = '<div class="media-gallery-item-wrapper">';
// Style the thumbnail as a link
$output .= theme('media_gallery_item', array(
'image' => $image,
'link_path' => $link_path,
'classes' => $classes,
));
// Close the wrapper
$output .= '</div>';
return $output;
}