From 25166c218be4e1ce1cb098de274a231b623d527e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 26 Feb 2024 09:00:35 +0100 Subject: RSS thumbnails (#5972) * Added addtional media:content for thumbnails * Fix whitespace * More attributes for enclosures * Fix variable * Fix variable * No duplicates --------- Co-authored-by: root --- app/views/index/rss.phtml | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'app/views') diff --git a/app/views/index/rss.phtml b/app/views/index/rss.phtml index 0205b0703..1c036abd2 100644 --- a/app/views/index/rss.phtml +++ b/app/views/index/rss.phtml @@ -41,28 +41,38 @@ foreach ($this->entries as $item) { echo "\t\t\t", '', $category, '', "\n"; } } + + $enclosures = iterator_to_array($item->enclosures(false)); $thumbnail = $item->thumbnail(false); if (!empty($thumbnail['url'])) { // https://www.rssboard.org/media-rss#media-thumbnails echo "\t\t\t", '', "\n"; + // Mostly for MailChimp + Feedbro which do not support https://mailchimp.com/help/rss-merge-tags/ + $thumbnail['medium'] ??= 'image'; + array_unshift($enclosures, $thumbnail); } - $enclosures = $item->enclosures(false); - if (is_iterable($enclosures)) { - foreach ($enclosures as $enclosure) { - // https://www.rssboard.org/media-rss - echo "\t\t\t", '' - . (empty($enclosure['title']) ? '' : '' . $enclosure['title'] . '') - . (empty($enclosure['credit']) ? '' : '' . $enclosure['credit'] . '') - . '', "\n"; + + $urls = []; + foreach ($enclosures as $enclosure) { + if (empty($enclosure['url']) || isset($urls[$enclosure['url']])) { + continue; } + $urls[$enclosure['url']] = true; + // https://www.rssboard.org/media-rss + echo "\t\t\t", '' + . (empty($enclosure['title']) ? '' : '' . $enclosure['title'] . '') + . (empty($enclosure['credit']) ? '' : '' . $enclosure['credit'] . '') + . '', "\n"; } ?>