aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-07-10 15:29:45 +0200
committerJoas Schilling <coding@schilljs.com>2024-07-17 09:24:55 +0200
commit693a81bfa367089de4b61ee1ea104c85e6bc6d1c (patch)
treefc98b9adef2985e640f1cf9f95d91f63dd7257f8 /apps/theming
parent2f9fcc22aec918a9d07603b5e481d43bfb980ba0 (diff)
downloadnextcloud-server-693a81bfa367089de4b61ee1ea104c85e6bc6d1c.tar.gz
nextcloud-server-693a81bfa367089de4b61ee1ea104c85e6bc6d1c.zip
fix(mail): Fix big logos in mail templates for Outlook
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/lib/ImageManager.php23
1 files changed, 23 insertions, 0 deletions
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;
}