From 98f0eb0322e22ed7d203e0fd21d7c652f29361c4 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 18 Dec 2024 11:27:00 +0100 Subject: [PATCH] Add `IUserCoverPhoto::getThumbnailURL()` --- .../user/cover/photo/DefaultUserCoverPhoto.class.php | 6 ++++++ .../lib/data/user/cover/photo/IUserCoverPhoto.class.php | 9 +++++++++ .../lib/data/user/cover/photo/UserCoverPhoto.class.php | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/wcfsetup/install/files/lib/data/user/cover/photo/DefaultUserCoverPhoto.class.php b/wcfsetup/install/files/lib/data/user/cover/photo/DefaultUserCoverPhoto.class.php index 00ad124e03..e63d940f7e 100644 --- a/wcfsetup/install/files/lib/data/user/cover/photo/DefaultUserCoverPhoto.class.php +++ b/wcfsetup/install/files/lib/data/user/cover/photo/DefaultUserCoverPhoto.class.php @@ -50,4 +50,10 @@ class DefaultUserCoverPhoto implements IUserCoverPhoto { return null; } + + #[\Override] + public function getThumbnailURL(string $size = 'small'): string + { + return $this->getURL(); + } } diff --git a/wcfsetup/install/files/lib/data/user/cover/photo/IUserCoverPhoto.class.php b/wcfsetup/install/files/lib/data/user/cover/photo/IUserCoverPhoto.class.php index ce1be6d9dd..ada928087f 100644 --- a/wcfsetup/install/files/lib/data/user/cover/photo/IUserCoverPhoto.class.php +++ b/wcfsetup/install/files/lib/data/user/cover/photo/IUserCoverPhoto.class.php @@ -26,6 +26,13 @@ interface IUserCoverPhoto */ public function getURL(?bool $forceWebP = null): string; + /** + * Returns the thumbnail of this cover photo. + * + * @since 6.2 + */ + public function getThumbnailURL(string $size = 'small'): string; + /** * Returns the file name of this cover photo. */ @@ -33,6 +40,8 @@ interface IUserCoverPhoto /** * Returns the object ID of this cover photo. + * + * @since 6.2 */ public function getObjectID(): ?int; } diff --git a/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php b/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php index 54aec222da..688b92f76f 100644 --- a/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php +++ b/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php @@ -50,6 +50,14 @@ final class UserCoverPhoto implements IUserCoverPhoto return $this->file->getFullSizeImageSource(); } + #[\Override] + public function getThumbnailURL(string $size = 'small'): string + { + $thumbnail = $this->file->getThumbnail($size); + + return $thumbnail ? $thumbnail->getLink() : $this->getURL(); + } + #[\Override] public function getFilename(?bool $forceWebP = null): string { -- 2.20.1