You are here

function theme_media_admin_thumbnail in D7 Media 7

Theme a thumbnail.

Parameters

$variables: array items being passed in

1 theme call to theme_media_admin_thumbnail()
theme_media_browser_thumbnails in includes/media.theme.inc
Display a item list of files as thumbnails. Implements the admin thumbnail theme for now- serves as a wrapper

File

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

Code

function theme_media_admin_thumbnail($variables) {
  $path = drupal_get_path('module', 'media');
  $file = $variables['file'];
  $style_name = $variables['style_name'];
  if (isset($file)) {
    $file_url = file_create_url($file->uri);
  }
  else {
    return '';
  }
  $output = '';
  if (module_exists('styles')) {
    $thumbnail = theme('styles', array(
      'field_type' => 'file',
      'style_name' => $style_name,
      'uri' => $file->uri,
      'description' => t('Thumbnail for !filename.', array(
        '!filename' => $file->filename,
      )),
      'object' => $variables['file'],
    ));
  }
  else {

    // Display a thumbnail for images.
    if (strstr($file->filemime, 'image')) {
      $thumbnail = theme('image_style', array(
        'style_name' => 'thumbnail',
        'path' => $file->uri,
        'alt' => t('Thumbnail for !filename.', array(
          '!filename' => $file->filename,
        )),
      ));
    }
    else {
      $thumbnail = theme('image', array(
        'path' => $path . '/images/file-unknown.png',
        'alt' => t('Thumbnail for !filename.', array(
          '!filename' => $file->filename,
        )),
        'attributes' => array(
          'class' => 'file-unknown',
        ),
      ));
    }
  }
  $output .= l($thumbnail, $file_url, array(
    'html' => TRUE,
    'attributes' => array(
      'class' => 'media-thumbnail',
    ),
  ));
  return $output;
}