diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-20 10:30:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 10:30:02 +0200 |
commit | d8030c8155ee4c20573848b2444f6df0b65d1662 (patch) | |
tree | b6c0b8208f004e1b2b37b1af54e8d4c40310d56e /application/bookmark/Bookmark.php | |
parent | 9b3c1270bcbe4f8e30e0160da8badd43dd94871a (diff) | |
parent | 21e72da9ee34cec56b10c83ae0c75b4bf320dfcb (diff) | |
download | Shaarli-d8030c8155ee4c20573848b2444f6df0b65d1662.tar.gz Shaarli-d8030c8155ee4c20573848b2444f6df0b65d1662.tar.zst Shaarli-d8030c8155ee4c20573848b2444f6df0b65d1662.zip |
Merge pull request #1584 from ArthurHoaro/feature/async-thumbnail-retrieval
Asynchronous retrieval of bookmark's thumbnails
Diffstat (limited to 'application/bookmark/Bookmark.php')
-rw-r--r-- | application/bookmark/Bookmark.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/application/bookmark/Bookmark.php b/application/bookmark/Bookmark.php index ea565d1f..4810c5e6 100644 --- a/application/bookmark/Bookmark.php +++ b/application/bookmark/Bookmark.php | |||
@@ -378,6 +378,24 @@ class Bookmark | |||
378 | } | 378 | } |
379 | 379 | ||
380 | /** | 380 | /** |
381 | * Return true if: | ||
382 | * - the bookmark's thumbnail is not already set to false (= not found) | ||
383 | * - it's not a note | ||
384 | * - it's an HTTP(S) link | ||
385 | * - the thumbnail has not yet be retrieved (null) or its associated cache file doesn't exist anymore | ||
386 | * | ||
387 | * @return bool True if the bookmark's thumbnail needs to be retrieved. | ||
388 | */ | ||
389 | public function shouldUpdateThumbnail(): bool | ||
390 | { | ||
391 | return $this->thumbnail !== false | ||
392 | && !$this->isNote() | ||
393 | && startsWith(strtolower($this->url), 'http') | ||
394 | && (null === $this->thumbnail || !is_file($this->thumbnail)) | ||
395 | ; | ||
396 | } | ||
397 | |||
398 | /** | ||
381 | * Get the Sticky. | 399 | * Get the Sticky. |
382 | * | 400 | * |
383 | * @return bool | 401 | * @return bool |