You are here

function file_displays_load in File Entity (fieldable files) 7.3

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

Returns an array of {file_display} objects for the file type and view mode.

Related topics

3 calls to file_displays_load()
file_displays in ./file_entity.file_api.inc
Returns an array of displays to use for a file type in a given view mode.
file_entity_file_display_form in ./file_entity.admin.inc
Form callback; presents file display settings for a given view mode.
file_entity_file_display_form_submit in ./file_entity.admin.inc
Process file display settings form submissions.

File

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

Code

function file_displays_load($file_type, $view_mode, $key_by_formatter_name = FALSE) {
  ctools_include('export');
  $display_names = array();
  $prefix = $file_type . '__' . $view_mode . '__';
  foreach (array_keys(file_info_formatter_types()) as $formatter_name) {
    $display_names[] = $prefix . $formatter_name;
  }
  $displays = ctools_export_load_object('file_display', 'names', $display_names);
  if ($key_by_formatter_name) {
    $prefix_length = strlen($prefix);
    $rekeyed_displays = array();
    foreach ($displays as $name => $display) {
      $rekeyed_displays[substr($name, $prefix_length)] = $display;
    }
    $displays = $rekeyed_displays;
  }
  return $displays;
}