You are here

function theme_brightcove_field_dialog_player in Brightcove Video Connect 7.2

Theme callback for Default thumbnail -> dialog player formatter.

1 string reference to 'theme_brightcove_field_dialog_player'
brightcove_field_theme in brightcove_field/brightcove_field.module
Implementation of hook_theme().

File

brightcove_field/brightcove_field.formatters.inc, line 37
Formatters for video field.

Code

function theme_brightcove_field_dialog_player($variables) {
  $element = $variables['element'];
  $image = $variables['image'];
  $style = $variables['style'];
  $entity_type = $variables['entity_type'];
  $entity = $variables['entity'];
  $field = $variables['field'];
  $display = $variables['display'];
  $delta = $variables['delta'];
  $entity_info = $entity_type ? entity_get_info($entity_type) : NULL;
  if (!empty($element['video_id'])) {
    $formatter_name = str_replace('dialog_player_', '', $display['type']);
    $video = brightcove_video_load($element['video_id']);
    $video_name = $video ? check_plain($video->name) : '';
    if (!$image) {
      $image = theme('image', empty($video->{$formatter_name}) ? array(
        'path' => brightcove_get_default_image(),
        'alt' => $video_name,
        'title' => $video_name,
        'width' => 120,
        'height' => 120,
      ) : array(
        'path' => $video->{$formatter_name},
      ));
    }
    $entity_id = $entity && $entity_info ? $entity->{$entity_info['entity keys']['id']} : 0;

    // loading theme.inc in order to make sure that the constants are loaded
    module_load_include('inc', 'brightcove_field', 'theme');
    $video_width = BRIGHTCOVE_VIDEO_DEFAULT_WIDTH;
    $video_height = BRIGHTCOVE_VIDEO_DEFAULT_HEIGHT;
    $dialog_width = $video_width;
    $dialog_height = $video_height;
    $destination = "brightcove_dialog/nojs/{$dialog_width}/{$dialog_height}/{$entity_type}/{$entity_id}/{$field['field_name']}/{$delta}";
    $output = l($image, $destination, array(
      'attributes' => array(
        'rel' => $field['field_name'],
        'class' => array(
          $field['field_name'],
          'use-ajax',
        ),
        'title' => $video ? check_plain($video->name) : '',
      ),
      'html' => TRUE,
    ));
    return theme('brightcove_field_dialog', array(
      'output' => $output,
      'video_id' => $element['video_id'],
      'video_width' => $video_width,
      'video_height' => $video_height,
      'dialog_width' => $dialog_width,
      'dialog_height' => $dialog_height,
      'destination' => $destination,
      'image_field' => $formatter_name,
      'field_name' => $field['field_name'],
      'entity_type' => $entity_type,
      'style' => $style,
    ));
  }
  return '';
}