getEntity(); // Add the first file as an enclosure to the RSS item. RSS allows only one // enclosure per item. See: http://wikipedia.org/wiki/RSS_enclosure foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) { $entity->rss_elements[] = [ 'key' => 'enclosure', 'attributes' => [ // In RSS feeds, it is necessary to use absolute URLs. The 'url.site' // cache context is already associated with RSS feed responses, so it // does not need to be specified here. 'url' => file_create_url($file->getFileUri()), 'length' => $file->getSize(), 'type' => $file->getMimeType(), ], ]; } return []; } }