diff options
author | Joas Schilling <coding@schilljs.com> | 2024-07-10 15:29:45 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-07-19 10:11:43 +0200 |
commit | b087e140e61ad413456cc11ece20a45592e16d26 (patch) | |
tree | f895ab2ec8560e190b2f340393cbf7f158d7672a /apps | |
parent | 9971121509351d54af29ba704ad5e8c55eeeb4d8 (diff) | |
download | nextcloud-server-b087e140e61ad413456cc11ece20a45592e16d26.tar.gz nextcloud-server-b087e140e61ad413456cc11ece20a45592e16d26.zip |
fix(mail): Fix big logos in mail templates for Outlook
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/tests/Mailer/NewUserMailHelperTest.php | 2 | ||||
-rw-r--r-- | apps/theming/lib/ImageManager.php | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php index 5c7d182d436..f731dfa4630 100644 --- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php +++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php @@ -85,6 +85,8 @@ class NewUserMailHelperTest extends TestCase { $this->defaults, $this->urlGenerator, $this->l10nFactory, + null, + null, 'test.TestTemplate', [] ); 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; } |