From bb9afc520bec634e403ed5d297500464162a6116 Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Wed, 30 Nov 2022 04:13:10 +0100 Subject: [PATCH] Added getBytesFromShorthand at the remaining places. --- src/Module/Media/Photo/Upload.php | 7 ++++++- src/Module/Settings/Profile/Photo/Index.php | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Module/Media/Photo/Upload.php b/src/Module/Media/Photo/Upload.php index c07249c902..ec8dbcf70d 100644 --- a/src/Module/Media/Photo/Upload.php +++ b/src/Module/Media/Photo/Upload.php @@ -26,6 +26,7 @@ use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Database\Database; +use Friendica\DI; use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Module\BaseApi; @@ -168,7 +169,11 @@ class Upload extends \Friendica\BaseModule $width = $image->getWidth(); $height = $image->getHeight(); - $maximagesize = $this->config->get('system', 'maximagesize'); + $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); + + if ($maximagesize == 0) { + $maximagesize = INF; + } if (!empty($maximagesize) && $filesize > $maximagesize) { // Scale down to multiples of 640 until the maximum size isn't exceeded anymore diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index d58576e757..ee551f88bc 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -53,7 +53,11 @@ class Index extends BaseSettings $filetype = Images::getMimeTypeBySource($src, $filename, $filetype); - $maximagesize = DI::config()->get('system', 'maximagesize', 0); + $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize', 0)); + + if ($maximagesize == 0) { + $maximagesize = INF; + } if ($maximagesize && $filesize > $maximagesize) { DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));