Added handling as infinity if maxfilesize is set to 0

This commit is contained in:
Marek Bachmann 2022-11-30 02:44:48 +01:00
parent ca7af7a64b
commit 97a3587e58
2 changed files with 16 additions and 1 deletions

View file

@ -576,6 +576,11 @@ class Photo
$filesize = strlen($image->asString());
$maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
if ($maximagesize == 0) {
$maximagesize = INF;
}
if (!empty($maximagesize) && ($filesize > $maximagesize)) {
Logger::info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $image->getType()]);
if ($image->getType() == 'image/gif') {
@ -968,6 +973,10 @@ class Photo
$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
foreach ([5120, 2560, 1280, 640] as $pixels) {