Commit 1921633a authored by Dave Reid's avatar Dave Reid Committed by olstjos
Browse files

Issue #2737817 by Dave Reid, joelstein, xlin1003: Undefined property:...

Issue #2737817 by Dave Reid, joelstein, xlin1003: Undefined property: stdClass::$fid in file_build_content() (line 173
parent 523093fd
Loading
Loading
Loading
Loading
+12 −6
Changes for file_entity.field.inc: 12 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -272,6 +272,18 @@ function file_entity_field_formatter_settings_summary($field, $instance, $view_m
  return implode('<br />', $summary);
}

/**
 * Implements hook_field_formatter_prepare_view().
 */
function file_entity_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
  // File and image fields set item values to NULL if a file cannot be loaded.
  // Remove those empty items so we can simply iterate through $items normally
  // in file_entity_field_formatter_view().
  foreach (array_keys($entities) as $id) {
    $items[$id] = array_filter($items[$id]);
  }
}

/**
 * Implements hook_field_formatter_view().
 */
@@ -356,9 +368,6 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan
    case 'file_audio':
      $multiple_file_behavior = $settings['multiple_file_behavior'];

      // Prevent 'empty' fields from causing a WSOD.
      $items = array_filter($items);

      // Build an array of sources for each <audio> element.
      $source_lists = array();
      if ($multiple_file_behavior == 'tags') {
@@ -392,9 +401,6 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan
    case 'file_video':
      $multiple_file_behavior = $settings['multiple_file_behavior'];

      // Prevent 'empty' fields from causing a WSOD.
      $items = array_filter($items);

      // Build an array of sources for each <video> element.
      $source_lists = array();
      if ($multiple_file_behavior == 'tags') {