You are here

function file_view_multiple in File Entity (fieldable files) 7

Same name and namespace in other branches
  1. 7.3 file_entity.file_api.inc \file_view_multiple()
  2. 7.2 file_entity.file_api.inc \file_view_multiple()

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().

1 call to file_view_multiple()
file_entity_field_formatter_view in ./file_entity.field.inc
Implements hook_field_formatter_view().
1 string reference to 'file_view_multiple'
file_entity_entity_info_alter in ./file_entity.module
Implements hook_entity_info_alter().

File

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

Code

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