You are here

function mediafield_field_formatter_view in D7 Media 7.2

Same name and namespace in other branches
  1. 7.4 modules/mediafield/mediafield.module \mediafield_field_formatter_view()
  2. 7.3 modules/mediafield/mediafield.module \mediafield_field_formatter_view()

Implements hook_field_formatter_view().

File

modules/mediafield/mediafield.module, line 129
Provide a "Multimedia asset" field.

Code

function mediafield_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $files = array();
  foreach ($items as $delta => $item) {
    if (!empty($item['file'])) {
      $files[$item['fid']] = $item['file'];
    }
  }
  if (!empty($files)) {
    $output = file_view_multiple($files, $display['settings']['file_view_mode'], 0, $langcode);

    // Remove the first level from the output array.
    $element = reset($output);
  }
  return $element;
}