aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-07-17 11:54:47 +0200
committerGitHub <noreply@github.com>2024-07-17 11:54:47 +0200
commit05888991d70b48ab82953306be83f22c65cfe791 (patch)
tree931f914e1aff27969122435aa788fe054091e980 /apps
parent4362ed53614c900c53986b694ea3eea3799ab9c1 (diff)
parent693a81bfa367089de4b61ee1ea104c85e6bc6d1c (diff)
downloadnextcloud-server-05888991d70b48ab82953306be83f22c65cfe791.tar.gz
nextcloud-server-05888991d70b48ab82953306be83f22c65cfe791.zip
Merge pull request #46419 from nextcloud/bugfix/noid/limit-logo-size-for-outlook
fix(mail): Fix big logos in mail templates for Outlook
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/tests/Mailer/NewUserMailHelperTest.php2
-rw-r--r--apps/theming/lib/ImageManager.php23
2 files changed, 25 insertions, 0 deletions
diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
index 19cfab8c193..72af678f832 100644
--- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php
+++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
@@ -57,6 +57,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 761b0c9a8ba..4afdedf5189 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -194,6 +194,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 {
@@ -266,6 +270,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;
}