diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-07-22 09:00:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-22 09:00:11 +0200 |
commit | 03a08e3863dde0ac5231bbb7bbe3f3dcadbae918 (patch) | |
tree | 631205feeb40de60eb455a7233a9d4fcec97121c /apps/theming/lib | |
parent | cd24a8634bcf4b773aac734f6f9194d15d79a04b (diff) | |
parent | b087e140e61ad413456cc11ece20a45592e16d26 (diff) | |
download | nextcloud-server-03a08e3863dde0ac5231bbb7bbe3f3dcadbae918.tar.gz nextcloud-server-03a08e3863dde0ac5231bbb7bbe3f3dcadbae918.zip |
Merge pull request #46628 from nextcloud/backport/46419/stable28
[stable28] fix(mail): Fix big logos in mail templates for Outlook
Diffstat (limited to 'apps/theming/lib')
-rw-r--r-- | apps/theming/lib/ImageManager.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index f536bae0421..4fcb0aab24d 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -209,6 +209,10 @@ class ImageManager { } catch (NotFoundException $e) { } catch (NotPermittedException $e) { } + + if ($key === 'logo') { + $this->config->deleteAppValue('theming', 'logoDimensions'); + } } public function updateImage(string $key, string $tmpFile): string { @@ -272,6 +276,25 @@ class ImageManager { $target->putContent(file_get_contents($tmpFile)); + if ($key === 'logo') { + $content = file_get_contents($tmpFile); + $newImage = @imagecreatefromstring($content); + if ($newImage !== false) { + $this->config->setAppValue('theming', 'logoDimensions', imagesx($newImage) . 'x' . imagesy($newImage)); + } elseif (str_starts_with($detectedMimeType, 'image/svg')) { + $matched = preg_match('/viewbox=["\']\d* \d* (\d*\.?\d*) (\d*\.?\d*)["\']/i', $content, $matches); + if ($matched) { + $this->config->setAppValue('theming', 'logoDimensions', $matches[1] . 'x' . $matches[2]); + } else { + $this->logger->warning('Could not read logo image dimensions to optimize for mail header'); + $this->config->deleteAppValue('theming', 'logoDimensions'); + } + } else { + $this->logger->warning('Could not read logo image dimensions to optimize for mail header'); + $this->config->deleteAppValue('theming', 'logoDimensions'); + } + } + return $detectedMimeType; } |