aboutsummaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-02-26 09:00:35 +0100
committerGravatar GitHub <noreply@github.com> 2024-02-26 09:00:35 +0100
commit25166c218be4e1ce1cb098de274a231b623d527e (patch)
tree36ae287f372c36631fbcb2bf952f82cc4a02fb75 /app/views
parent84d88d4b5dbd12130344a02fa8dd2cfb2b55b96a (diff)
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 <root@ha-server.lan>
Diffstat (limited to 'app/views')
-rw-r--r--app/views/index/rss.phtml36
1 files changed, 23 insertions, 13 deletions
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>', $category, '</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", '<media:thumbnail url="' . $thumbnail['url']
. (empty($thumbnail['width']) ? '' : '" width="' . $thumbnail['width'])
. (empty($thumbnail['height']) ? '' : '" height="' . $thumbnail['height'])
- . (empty($thumbnail['type']) ? '' : '" type="' . $thumbnail['type'])
+ . (empty($thumbnail['time']) ? '' : '" time="' . $thumbnail['time'])
. '" />', "\n";
+ // Mostly for MailChimp + Feedbro which do not support <media:thumbnail> 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", '<media:content url="' . $enclosure['url']
- . (empty($enclosure['medium']) ? '' : '" medium="' . $enclosure['medium'])
- . (empty($enclosure['type']) ? '' : '" type="' . $enclosure['type'])
- . (empty($enclosure['length']) ? '' : '" length="' . $enclosure['length'])
- . '">'
- . (empty($enclosure['title']) ? '' : '<media:title type="html">' . $enclosure['title'] . '</media:title>')
- . (empty($enclosure['credit']) ? '' : '<media:credit>' . $enclosure['credit'] . '</media:credit>')
- . '</media:content>', "\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", '<media:content url="' . $enclosure['url']
+ . (empty($enclosure['medium']) ? '' : '" medium="' . $enclosure['medium'])
+ . (empty($enclosure['type']) ? '' : '" type="' . $enclosure['type'])
+ . (empty($enclosure['length']) ? '' : '" length="' . $enclosure['length'])
+ . (empty($enclosure['height']) ? '' : '" height="' . $enclosure['height'])
+ . (empty($enclosure['width']) ? '' : '" width="' . $enclosure['width'])
+ . '">'
+ . (empty($enclosure['title']) ? '' : '<media:title type="html">' . $enclosure['title'] . '</media:title>')
+ . (empty($enclosure['credit']) ? '' : '<media:credit>' . $enclosure['credit'] . '</media:credit>')
+ . '</media:content>', "\n";
}
?>
<description><![CDATA[<?php