You are here

function theme_media_thumbnail in D7 Media 7

Same name and namespace in other branches
  1. 7.4 includes/media.theme.inc \theme_media_thumbnail()
  2. 7.2 includes/media.theme.inc \theme_media_thumbnail()
  3. 7.3 includes/media.theme.inc \theme_media_thumbnail()

Adds a wrapper around a preview of a media file.

Parameters

unknown_type $element:

Return value

unknown_type

File

includes/media.theme.inc, line 277
Media Theming

Code

function theme_media_thumbnail($variables) {
  $label = '';
  $element = $variables['element'];
  $destination = drupal_get_destination();

  // Wrappers to go around the thumbnail
  $prefix = '<div class="media-item"><div class="media-thumbnail">';
  $suffix = '</div></div>';

  // Arguments for the thumbnail link
  $thumb = $element['#children'];
  $target = 'media/' . $element['#file']->fid . '/edit';
  $options = array(
    'query' => $destination,
    'html' => TRUE,
    'attributes' => array(
      'title' => t('Click to edit details'),
    ),
  );

  // Element should be a field renderable array... This is a little wonky - admitted.
  if (!empty($element['#show_names']) && $element['#name']) {
    $label = '<div class="label-wrapper"><label class="media-filename">' . $element['#name'] . '</label></div>';
  }

  // How can I attach CSS here?

  //$element['#attached']['css'][] = drupal_get_path('module', 'media') . '/css/media.css';
  drupal_add_css(drupal_get_path('module', 'media') . '/css/media.css');
  $output = $prefix;
  if (!empty($element['#add_link'])) {
    $output .= l($thumb, $target, $options);
  }
  else {
    $output .= $thumb;
  }
  $output .= $label . $suffix;
  return $output;
}