diff options
| author | 2021-01-12 09:34:13 +0100 | |
|---|---|---|
| committer | 2021-01-12 09:34:13 +0100 | |
| commit | 6d8b1ba834742f769dcf646d405f90676a8f5b28 (patch) | |
| tree | 5526d70baa05fc4e2b1af2a440e3ffb647aee130 /app/Models/Feed.php | |
| parent | 8dfe2097992307b572b42647b53a76dd5d93aaa9 (diff) | |
Fix images in enclosures without MIME type (#3361)
#fix https://github.com/FreshRSS/FreshRSS/issues/3358
Assume enclosures without a mime type, without a length, but with either
a width or a height are images
Diffstat (limited to 'app/Models/Feed.php')
| -rw-r--r-- | app/Models/Feed.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 7811d05b2..795337b01 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -405,23 +405,23 @@ class FreshRSS_Feed extends Minz_Model { $elinks[$elink] = true; $mime = strtolower($enclosure->get_type()); $medium = strtolower($enclosure->get_medium()); + $height = $enclosure->get_height(); + $width = $enclosure->get_width(); $length = $enclosure->get_length(); - if ($medium === 'image' || strpos($mime, 'image/') === 0) { + if (strpos($mime, 'image') === 0 || ($mime == '' && $length == null && ($width != 0 || $height != 0))) { $enclosureContent .= '<p class="enclosure-content"><img src="' . $elink . '" alt="" /></p>'; - } elseif ($medium === 'audio' || strpos($mime, 'audio/') === 0) { + } elseif (strpos($mime, 'audio') === 0) { $enclosureContent .= '<p class="enclosure-content"><audio preload="none" src="' . $elink . ($length == null ? '' : '" data-length="' . intval($length)) . '" data-type="' . htmlspecialchars($mime, ENT_COMPAT, 'UTF-8') . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>'; - } elseif ($medium === 'video' || strpos($mime, 'video/') === 0) { + } elseif (strpos($mime, 'video') === 0) { $enclosureContent .= '<p class="enclosure-content"><video preload="none" src="' . $elink . ($length == null ? '' : '" data-length="' . intval($length)) . '" data-type="' . htmlspecialchars($mime, ENT_COMPAT, 'UTF-8') . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>'; - } elseif ($medium != '' || strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { + } else { //e.g. application, text, unknown $enclosureContent .= '<p class="enclosure-content"><a download="" href="' . $elink . '">💾</a></p>'; - } else { - unset($elinks[$elink]); } $thumbnailContent = ''; |
