function theme_media_thumbnail in D7 Media 7.4
Same name and namespace in other branches
- 7 includes/media.theme.inc \theme_media_thumbnail()
- 7.2 includes/media.theme.inc \theme_media_thumbnail()
- 7.3 includes/media.theme.inc \theme_media_thumbnail()
Adds a wrapper around a preview of a media file.
File
- includes/
media.theme.inc, line 13 - Media Theming.
Code
function theme_media_thumbnail($variables) {
$label = '';
$element = $variables['element'];
// Wrappers to go around the thumbnail.
$attributes = array(
'title' => $element['#name'],
'class' => 'media-item',
'data-fid' => $element['#file']->fid,
);
$prefix = '<div ' . drupal_attributes($attributes) . '><div class="media-thumbnail">';
$suffix = '</div></div>';
// Arguments for the thumbnail link.
$thumb = $element['#children'];
if (file_entity_access('update', $element['#file'])) {
$target = 'file/' . $element['#file']->fid . '/edit';
$title = t('Click to edit details');
}
else {
$target = 'file/' . $element['#file']->fid;
$title = t('Click to view details');
}
$options = array(
'query' => drupal_get_destination(),
'html' => TRUE,
'attributes' => array(
'title' => $title,
),
);
// Element should be a field renderable array. This should be improved.
if (!empty($element['#show_names']) && $element['#name']) {
$label = '<div class="label-wrapper"><label class="media-filename">' . $element['#name'] . '</label></div>';
}
$output = $prefix;
if (!empty($element['#add_link'])) {
$output .= l($thumb, $target, $options);
}
else {
$output .= $thumb;
}
$output .= $label . $suffix;
return $output;
}