getEntitiesToView($items, $langcode) as $delta => $file) { $item = $file->_referringItem; $elements[$delta] = [ '#theme' => 'file_link', '#file' => $file, '#description' => $item->description, '#cache' => [ 'tags' => $file->getCacheTags(), ], ]; // Pass field item attributes to the theme function. if (isset($item->_attributes)) { $elements[$delta] += ['#attributes' => []]; $elements[$delta]['#attributes'] += $item->_attributes; // Unset field item attributes since they have been included in the // formatter output and should not be rendered in the field template. unset($item->_attributes); } } return $elements; } }