diff options
Diffstat (limited to 'lib/private/Mail/Mailer.php')
-rw-r--r-- | lib/private/Mail/Mailer.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 750a5ee80e5..77ba12c4852 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -79,6 +79,12 @@ use Symfony\Component\Mime\Exception\RfcComplianceException; * @package OC\Mail */ class Mailer implements IMailer { + // Do not move this block or change it's content without contacting the release crew + public const DEFAULT_DIMENSIONS = '252x120'; + // Do not move this block or change it's content without contacting the release crew + + public const MAX_LOGO_SIZE = 105; + private ?MailerInterface $instance = null; public function __construct( @@ -136,10 +142,37 @@ class Mailer implements IMailer { ); } + $logoDimensions = $this->config->getAppValue('theming', 'logoDimensions', self::DEFAULT_DIMENSIONS); + if (str_contains($logoDimensions, 'x')) { + [$width, $height] = explode('x', $logoDimensions); + $width = (int) $width; + $height = (int) $height; + + if ($width > self::MAX_LOGO_SIZE || $height > self::MAX_LOGO_SIZE) { + if ($width === $height) { + $logoWidth = self::MAX_LOGO_SIZE; + $logoHeight = self::MAX_LOGO_SIZE; + } elseif ($width > $height) { + $logoWidth = self::MAX_LOGO_SIZE; + $logoHeight = (int) (($height / $width) * self::MAX_LOGO_SIZE); + } else { + $logoWidth = (int) (($width / $height) * self::MAX_LOGO_SIZE); + $logoHeight = self::MAX_LOGO_SIZE; + } + } else { + $logoWidth = $width; + $logoHeight = $height; + } + } else { + $logoWidth = $logoHeight = null; + } + return new EMailTemplate( $this->defaults, $this->urlGenerator, $this->l10nFactory, + $logoWidth, + $logoHeight, $emailId, $data ); |