summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-11-01 23:20:22 +0100
committerGravatar GitHub <noreply@github.com> 2023-11-01 23:20:22 +0100
commit8b2f7848eb1054ee26048e3ffe76855410286407 (patch)
tree2c7ea8be49b381ccf1f7d78216bc9d750a873071
parent0795d47d82391b6679605390d809b2dbe6bfc127 (diff)
Add support for enclosures thumbnail (#5806)
* Add support for enclosures thumbnail fix https://github.com/FreshRSS/FreshRSS/issues/5170 * Changelog
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/Models/Entry.php13
2 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fef33948c..1526cef75 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
* Require PHP 7.4+, and implement *typed properties* [#5720](https://github.com/FreshRSS/FreshRSS/pull/5720)
* Require Apache 2.4+ (but repair minimal compatibility with Apache 2.2) [#5791](https://github.com/FreshRSS/FreshRSS/pull/5791), [#5804](https://github.com/FreshRSS/FreshRSS/pull/5804)
* Features
+ * Add support for more thumbnail types [#5806](https://github.com/FreshRSS/FreshRSS/pull/5806)
* Increase SQL (`VARCHAR`) text fields length to maximum possible [#5788](https://github.com/FreshRSS/FreshRSS/pull/5788)
* Increase SQL date fields to 64-bit to be ready for year 2038+ [#5570](https://github.com/FreshRSS/FreshRSS/pull/5570)
* Bug fixing
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;
}