You are here

function video_field_formatter_view in Video 7

Same name and namespace in other branches
  1. 7.2 video.field.inc \video_field_formatter_view()

Implements hook_field_formatter_view().

File

./video.field.inc, line 440
Implement an video field, based on the file module's file field.

Code

function video_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  // Check if the formatter involves a link.
  if ($display['settings']['video_link'] == 'content') {
    $uri = entity_uri($entity_type, $entity);
  }
  elseif ($display['settings']['video_link'] == 'file') {
    $link_file = TRUE;
  }

  // set the display
  $theme = $display['type'];
  foreach ($items as $delta => $item) {
    if (isset($link_file)) {
      $uri = array(
        'path' => file_create_url($item['uri']),
        'options' => array(),
      );
    }
    $element[$delta] = array(
      '#theme' => $theme,
      '#item' => $item,
      '#video_style' => $display['settings']['video_style'],
      '#path' => isset($uri) ? $uri : '',
      '#entity' => $entity,
      '#field' => $field,
      '#instance' => $instance,
    );
  }
  return $element;
}