From a473b90ff9533687e1347aed0d3b9ceaa5e66aab Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 27 Sep 2021 22:24:26 +0200 Subject: Detect enclosure as images using file extension (#3861) * Detect enclosure as images using file extension Support e.g. https://www.sciencesetavenir.fr/atom.xml , which does not include any type hint. ```html ``` Useful for https://github.com/FreshRSS/FreshRSS/pull/3805 * Add AVIF and WebP --- app/Models/Feed.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 423b913b0..a0bf8f353 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -410,7 +410,8 @@ class FreshRSS_Feed extends Minz_Model { $height = $enclosure->get_height(); $width = $enclosure->get_width(); $length = $enclosure->get_length(); - if ($medium === 'image' || strpos($mime, 'image') === 0 || ($mime == '' && $length == null && ($width != 0 || $height != 0))) { + if ($medium === 'image' || strpos($mime, 'image') === 0 || + ($mime == '' && $length == null && ($width != 0 || $height != 0 || preg_match('/[.](avif|gif|jpe?g|png|svg|webp)$/i', $elink)))) { $enclosureContent .= '

'; } elseif ($medium === 'audio' || strpos($mime, 'audio') === 0) { $enclosureContent .= '