*}{if $__wcf->getStyleHandler()->getStyle()->getVariable('pageLogoHeight')} height="{@$__wcf->getStyleHandler()->getStyle()->getVariable('pageLogoHeight')}"{/if}{*
*}{if $__wcf->getStyleHandler()->getStyle()->getVariable('pageLogoWidth')} width="{@$__wcf->getStyleHandler()->getStyle()->getVariable('pageLogoWidth')}"{/if}{*
*} loading="eager">
- <img src="{$__wcf->getStyleHandler()->getStyle()->getPageLogoMobile()}" alt="" class="pageHeaderLogoSmall" loading="eager">
+ <img src="{$__wcf->getStyleHandler()->getStyle()->getPageLogoMobile()}" alt="" class="pageHeaderLogoSmall"{*
+ *}{if $__wcf->getStyleHandler()->getStyle()->getPageLogoSmallHeight()} height="{@$__wcf->getStyleHandler()->getStyle()->getPageLogoSmallHeight()}"{/if}{*
+ *}{if $__wcf->getStyleHandler()->getStyle()->getPageLogoSmallWidth()} width="{@$__wcf->getStyleHandler()->getStyle()->getPageLogoSmallWidth()}"{/if}{*
+ *} loading="eager">
{event name='headerLogo'}
</a>
*/
class Style extends DatabaseObject
{
+ /**
+ * @since 5.4
+ */
+ protected $pageLogoSmallHeight = 0;
+
+ /**
+ * @since 5.4
+ */
+ protected $pageLogoSmallWidth = 0;
+
/**
* list of style variables
* @var string[]
if (empty($this->variables['wcfPageThemeColor'])) {
$this->variables['wcfPageThemeColor'] = $this->variables['wcfHeaderBackground'];
}
+
+ // Fetch the dimensions of the small logo, avoding calls to `getimagesize` with every request.
+ $filename = \WCF_DIR . 'images/default-logo-small.png';
+ if ($this->getVariable('pageLogoMobile')) {
+ $filename = \WCF_DIR;
+ if ($this->imagePath) {
+ $filename .= $this->imagePath;
+ }
+
+ $filename .= $this->getVariable('pageLogoMobile');
+ }
+
+ if (\file_exists($filename)) {
+ $data = \getimagesize($filename);
+ if ($data !== false) {
+ $this->pageLogoSmallWidth = $data[0];
+ $this->pageLogoSmallHeight = $data[1];
+ }
+ }
}
/**
return WCF::getPath() . 'images/coverPhotos/' . $this->getCoverPhoto();
}
+ /**
+ * @since 5.4
+ */
+ public function getPageLogoSmallHeight(): int {
+ return $this->pageLogoSmallHeight;
+ }
+
+ /**
+ * @since 5.4
+ */
+ public function getPageLogoSmallWidth(): int
+ {
+ return $this->pageLogoSmallWidth;
+ }
+
/**
* Serve the WebP variant of the cover photo if the browser supports
* it and the original cover photo is not a GIF.