File tree Expand file tree Collapse file tree
wcfsetup/install/files/lib/system/image/cover/photo Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33namespace wcf \system \image \cover \photo ;
44
55use wcf \system \style \StyleHandler ;
6+ use wcf \util \FileUtil ;
67
78/**
89 * Represents the default cover photo as defined in the style configuration.
@@ -41,6 +42,18 @@ public function getHeight(?string $size = null): int
4142 return $ this ->getDimensions ()['height ' ];
4243 }
4344
45+ #[\Override]
46+ public function getFileSize (?string $ size = null ): int
47+ {
48+ return \filesize (StyleHandler::getInstance ()->getStyle ()->getCoverPhotoLocation ());
49+ }
50+
51+ #[\Override]
52+ public function getMimeType (?string $ size = null ): string
53+ {
54+ return FileUtil::getMimeType (StyleHandler::getInstance ()->getStyle ()->getCoverPhotoLocation ());
55+ }
56+
4457 /**
4558 * @return array{height: int, width: int}
4659 */
Original file line number Diff line number Diff line change @@ -54,4 +54,31 @@ public function getHeight(?string $size = null): int
5454
5555 return $ this ->file ->height ;
5656 }
57+
58+ #[\Override]
59+ public function getFileSize (?string $ size = null ): int
60+ {
61+ if ($ size !== null ) {
62+ $ thumbnail = $ this ->file ->getThumbnail ($ size );
63+ if ($ thumbnail !== null ) {
64+ return \filesize ($ thumbnail ->getPathname ());
65+ }
66+ }
67+
68+ return $ this ->file ->fileSize ;
69+ }
70+
71+ #[\Override]
72+ public function getMimeType (?string $ size = null ): string
73+ {
74+ if ($ size !== null ) {
75+ $ thumbnail = $ this ->file ->getThumbnail ($ size );
76+ if ($ thumbnail !== null ) {
77+ // Thumbnails are always webp.
78+ return 'image/webp ' ;
79+ }
80+ }
81+
82+ return $ this ->file ->mimeType ;
83+ }
5784}
Original file line number Diff line number Diff line change @@ -17,4 +17,8 @@ public function getUrl(?string $size = null): string;
1717 public function getWidth (?string $ size = null ): int ;
1818
1919 public function getHeight (?string $ size = null ): int ;
20+
21+ public function getFileSize (?string $ size = null ): int ;
22+
23+ public function getMimeType (?string $ size = null ): string ;
2024}
You can’t perform that action at this time.
0 commit comments