diff options
| author | 2018-06-06 21:29:22 +0200 | |
|---|---|---|
| committer | 2018-06-06 21:29:22 +0200 | |
| commit | 7ab4a2609a4db8babb968f79cc2832ec0a02ce09 (patch) | |
| tree | b31dc9fff8eb0a5b537d1d1a9a369a384716b6dd /app/Models | |
| parent | afad1d11af812538fe01d274ac3b9311e033e5a6 (diff) | |
Support for media: tags (#1920)
* Support for media: tags
https://github.com/FreshRSS/FreshRSS/issues/944
E.g. YouTube
* Fix for medium attribute
* Changelog 944
https://github.com/FreshRSS/FreshRSS/issues/944
https://github.com/FreshRSS/FreshRSS/pull/1920
* enclosure styling
* Compatibility old enclosure content
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/Feed.php | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index c8ccff09b..07a7a5459 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -359,21 +359,45 @@ class FreshRSS_Feed extends Minz_Model { foreach ($item->get_enclosures() as $enclosure) { $elink = $enclosure->get_link(); if ($elink != '' && empty($elinks[$elink])) { - $elinks[$elink] = '1'; + $content .= '<div class="enclosure">'; + + if ($enclosure->get_title() != '') { + $content .= '<p class="enclosure-title">' . $enclosure->get_title() . '</p>'; + } + + $enclosureContent = ''; + $elinks[$elink] = true; $mime = strtolower($enclosure->get_type()); - if (strpos($mime, 'image/') === 0) { - $content .= '<p class="enclosure"><img src="' . $elink . '" alt="" /></p>'; - } elseif (strpos($mime, 'audio/') === 0) { - $content .= '<p class="enclosure"><audio preload="none" src="' . $elink + $medium = strtolower($enclosure->get_medium()); + if ($medium === 'image' || strpos($mime, 'image/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><img src="' . $elink . '" alt="" /></p>'; + } elseif ($medium === 'audio' || strpos($mime, 'audio/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><audio preload="none" src="' . $elink . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>'; - } elseif (strpos($mime, 'video/') === 0) { - $content .= '<p class="enclosure"><video preload="none" src="' . $elink + } elseif ($medium === 'video' || strpos($mime, 'video/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><video preload="none" src="' . $elink . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>'; - } elseif (strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { - $content .= '<p class="enclosure"><a download="" href="' . $elink . '">💾</a></p>'; + } elseif ($medium != '' || strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><a download="" href="' . $elink . '">💾</a></p>'; } else { unset($elinks[$elink]); } + + $thumbnailContent = ''; + foreach ($enclosure->get_thumbnails() as $thumbnail) { + if (empty($elinks[$thumbnail])) { + $elinks[$thumbnail] = true; + $thumbnailContent .= '<p><img class="enclosure-thumbnail" src="' . $thumbnail . '" alt="" /></p>'; + } + } + + $content .= $thumbnailContent; + $content .= $enclosureContent; + + if ($enclosure->get_description() != '') { + $content .= '<pre class="enclosure-description">' . $enclosure->get_description() . '</pre>'; + } + $content .= "</div>\n"; } } |
