diff options
| author | 2023-11-01 23:20:22 +0100 | |
|---|---|---|
| committer | 2023-11-01 23:20:22 +0100 | |
| commit | 8b2f7848eb1054ee26048e3ffe76855410286407 (patch) | |
| tree | 2c7ea8be49b381ccf1f7d78216bc9d750a873071 /app/Models/Entry.php | |
| parent | 0795d47d82391b6679605390d809b2dbe6bfc127 (diff) | |
Add support for enclosures thumbnail (#5806)
* Add support for enclosures thumbnail
fix https://github.com/FreshRSS/FreshRSS/issues/5170
* Changelog
Diffstat (limited to 'app/Models/Entry.php')
| -rw-r--r-- | app/Models/Entry.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php index e3e61fb00..3e9cee4e2 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -298,11 +298,24 @@ HTML; */ public function thumbnail(bool $searchEnclosures = true): ?array { $thumbnail = $this->attributes('thumbnail'); + // First, use the provided thumbnail, if any if (!empty($thumbnail['url'])) { return $thumbnail; } if ($searchEnclosures) { foreach ($this->enclosures(true) as $enclosure) { + // Second, search each enclosure’s thumbnails + if (!empty($enclosure['thumbnails'][0])) { + foreach ($enclosure['thumbnails'] as $src) { + if (is_string($src)) { + return [ + 'url' => $src, + 'medium' => 'image', + ]; + } + } + } + // Third, check whether each enclosure itself is an appropriate image if (self::enclosureIsImage($enclosure)) { return $enclosure; } |
