You are here

function theme_video_thumbnail in Video 7

File

./video.theme.inc, line 84

Code

function theme_video_thumbnail($variables) {

  // Inside a view $variables may contain null data. In that case, just return.
  if (empty($variables['item']['fid'])) {
    return '<!-- File not found: ' . $variables['item']['fid'] . ' -->';
  }

  //setup our thumbnail object
  module_load_include('inc', 'video', '/includes/video_helper');
  $video_helper = new video_helper();

  // @TODO : change the object to an array
  $thumbnail = (array) $video_helper
    ->thumbnail_object($variables);

  // return if no file path found for the video thumbnails and add log message
  if (empty($thumbnail['filepath'])) {
    watchdog('video', 'Unable to find the video thumbnail for the %node.', array(
      '%node' => $variables['entity']->title,
    ), WATCHDOG_ERROR);
    return '<!-- File not found: ' . $thumbnail['filepath'] . ' -->';
  }
  $image = array(
    'path' => $thumbnail['filepath'],
    'alt' => $thumbnail['alt'],
  );

  // Do not output an empty 'title' attribute.
  if (drupal_strlen($thumbnail['title']) > 0) {
    $image['title'] = $thumbnail['title'];
  }
  if ($variables['video_style']) {
    $image['style_name'] = $variables['video_style'];
    $output = theme('image_style', $image);
  }
  else {
    $output = theme('image', $image);
  }
  if ($variables['path']) {
    $path = $variables['path']['path'];
    $options = $variables['path']['options'];

    // When displaying an image inside a link, the html option must be TRUE.
    $options['html'] = TRUE;
    $output = l($output, $path, $options);
  }
  return $output;
}