You are here

public function video_helper::thumbnail_object in Video 7

Same name and namespace in other branches
  1. 6.5 includes/video_helper.inc \video_helper::thumbnail_object()
  2. 6.4 includes/video_helper.inc \video_helper::thumbnail_object()
1 call to video_helper::thumbnail_object()
video_helper::video_object in includes/video_helper.inc

File

includes/video_helper.inc, line 72

Class

video_helper

Code

public function thumbnail_object($variables) {
  $field_settings = $variables['field']['settings'];
  $instance_settings = $variables['instance']['settings'];

  // Build our thumbnail object
  $thumbnail = new stdClass();
  $thumbnail->filepath = '';
  $thumbnail->url = '';

  //@todo future enhancements for our thumbnails
  $thumbnail->alt = $variables['entity']->title;
  $thumbnail->title = $variables['entity']->title;

  //    $thumbnail->description = '';
  // Setup our thumbnail path.
  $use_default_img = isset($variables['item']['use_default_video_thumb']) ? TRUE : FALSE;
  if ($use_default_img && !empty($field_settings['default_video_thumbnail'])) {
    $default_thumbnail = file_load($field_settings['default_video_thumbnail']['fid']);

    // Check the checkbox to use default thumbnail on node
    $thumbnail->filepath = $default_thumbnail->uri;
  }
  elseif (isset($variables['item']['thumbnail']) ? TRUE : FALSE) {

    // actual video thumbnails is present
    $thumbnail_load = file_load($variables['item']['thumbnail']);
    $thumbnail->filepath = $thumbnail_load->uri;
  }
  else {

    //need some type of default if nothing is present

    //      drupal_set_message(t('No thumbnail has been configured for the video !title.', array('!title' => $variables['entity']->title)), 'error');
    return;
  }
  $thumbnail->url = file_create_url($thumbnail->filepath);

  // uri
  $thumbnail->uri = $thumbnail->filepath;

  //mime
  $thumbnail->filemime = file_get_mimetype($thumbnail->filepath);

  //swftools appends sites/default/files to the front of our path...

  //@todo Is this a setting?  Need to figure this out.
  $thumbnail->swfthumb = $thumbnail->filepath;

  // Return our object
  return $thumbnail;
}