You are here

function theme_video_formatter_video_colorbox in Video 6.5

Same name and namespace in other branches
  1. 6.4 video_formatter.inc \theme_video_formatter_video_colorbox()

Renders the video thumbnail linked to the absolute filepath of the video.

Colorbox is introduced to handle the video in an overlay.

@todo Very unstable, need better methods of integration. Seems hackish right now to find out what flv player is being used. We are also using jmedia for all other filetypes.

File

./video_formatter.inc, line 98
Video formatter hooks and callbacks.

Code

function theme_video_formatter_video_colorbox($element, $imagecache = FALSE) {
  global $base_path;
  if (!module_exists('colorbox')) {
    drupal_set_message(t('You must download and enable <a href="@colorbox-link">Colorbox</a> for this formatter.', array(
      '@colorbox-link' => 'http://www.drupal.org/project/colorbox',
    )), 'error');
    return theme('video_formatter_video_nodelink', $element);
  }

  // Inside a view $element may contain null data. In that case, just return.
  if (empty($element['#item']['fid'])) {
    return '';
  }

  // Load up our media plugins
  drupal_add_js(drupal_get_path('module', 'video') . '/js/jquery.media.js');
  drupal_add_js(drupal_get_path('module', 'video') . '/js/jquery.metadata.js');
  drupal_add_js(drupal_get_path('module', 'video') . '/js/flowplayer-3.2.0.min.js');

  // Setup our video object
  module_load_include('inc', 'video', '/includes/video_helper');
  $video_helper = new video_helper();
  $video = $video_helper
    ->video_object($element);
  $action = swftools_get_action($video->filepath);
  $player = swftools_get_player($action);
  $path = explode("_", $player);
  $player_url = $base_path . swftools_get_player_path() . '/' . $path[0] . '/' . variable_get($player . '_file', '');
  if (stristr($player, 'flowplayer')) {
    $player = 'flowplayer';
  }

  // Add our default settings to the Drupal.settings object
  $settings = array(
    'video' => array(
      'flvplayer' => $player_url,
      'autoplay' => $video->autoplay,
      'autobuffer' => $video->autobuffering,
      'player' => $player,
    ),
  );
  drupal_add_js($settings, 'setting');
  $image = theme('video_image', $video->thumbnail, $video->thumbnail->alt, $video->thumbnail->title, '', TRUE, $imagecache);
  $class = 'video-box video-' . $element['#field_name'] . '{width:\'' . $video->player_width . 'px\', height:\'' . $video->player_height . 'px\', player:\'' . $player . '\'}';
  return l($image, $video->files->{$video->player}->url, array(
    'attributes' => array(
      'class' => $class,
    ),
    'html' => TRUE,
  ));
}