From 3d80691aed03b2f5d6d1d8f45c9506fdaa2d6973 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 1 Jun 2021 14:10:45 +0200 Subject: [PATCH] Helper methods to query the style's cover photo dimensions --- .../files/lib/data/style/Style.class.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/wcfsetup/install/files/lib/data/style/Style.class.php b/wcfsetup/install/files/lib/data/style/Style.class.php index c3ad2e4c96..0fc15e650a 100644 --- a/wcfsetup/install/files/lib/data/style/Style.class.php +++ b/wcfsetup/install/files/lib/data/style/Style.class.php @@ -41,6 +41,16 @@ use wcf\util\ImageUtil; */ class Style extends DatabaseObject { + /** + * @since 5.4 + */ + protected $coverPhotoHeight = 0; + + /** + * @since 5.4 + */ + protected $coverPhotoWidth = 0; + /** * @since 5.4 */ @@ -223,6 +233,15 @@ class Style extends DatabaseObject $this->pageLogoSmallHeight = $data[1]; } } + + $coverPhoto = $this->getCoverPhotoLocation(); + if (\file_exists($coverPhoto)) { + $data = \getimagesize($coverPhoto); + if ($data !== false) { + $this->coverPhotoWidth = $data[0]; + $this->coverPhotoHeight = $data[1]; + } + } } /** @@ -339,6 +358,22 @@ class Style extends DatabaseObject return WCF::getPath() . 'images/coverPhotos/' . $this->getCoverPhoto(); } + /** + * @since 5.4 + */ + public function getCoverPhotoHeight(): int + { + return $this->coverPhotoHeight; + } + + /** + * @since 5.4 + */ + public function getCoverPhotoWidth(): int + { + return $this->coverPhotoWidth; + } + /** * @since 5.4 */ -- 2.20.1