You are here

function file_view_multiple in D7 Media 7

Construct a drupal_render() style array from an array of loaded files.

Parameters

$files: An array of files as returned by file_load_multiple().

$view_mode: View mode.

$weight: An integer representing the weight of the first file in the list.

$langcode: A string indicating the language field values are to be shown in. If no language is provided the current content language is used.

Return value

An array in the format expected by drupal_render().

2 calls to file_view_multiple()
file_entity_field_formatter_view in file_entity/file_entity.field.inc
Implements hook_field_formatter_view().
media_field_formatter_view in includes/media.fields.inc
Implement hook_field_formatter_view().

File

file_entity/file_entity.file_api.inc, line 123
API extensions of Drupal core's file.inc.

Code

function file_view_multiple($files, $view_mode = 'default', $weight = 0, $langcode = NULL) {
  if (empty($files)) {
    return array();
  }
  field_attach_prepare_view('file', $files, $view_mode);
  entity_prepare_view('file', $files);
  $build = array();
  foreach ($files as $file) {
    $build[$file->fid] = file_view($file, $view_mode, $langcode);
    $build[$file->fid]['#weight'] = $weight;
    $weight++;
  }
  $build['#sorted'] = TRUE;
  return $build;
}