Skip to content

Commit ced0cdf

Browse files
authored
Merge pull request #6621 from WoltLab/62-resize-avatars
Graceful handling of undersized avatars
2 parents 3749932 + 600cbdd commit ced0cdf

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function execute()
270270

271271
$width = $avatar->width;
272272
$height = $avatar->height;
273-
if ($width != $height) {
273+
if ($width !== $height && $width >= UserAvatarFileProcessor::AVATAR_SIZE && $height >= UserAvatarFileProcessor::AVATAR_SIZE) {
274274
// make avatar quadratic
275275
// minimum size is 128x128, maximum size is 256x256
276276
$width = $height = \min(
@@ -293,10 +293,13 @@ public function execute()
293293
$thumbnail = null;
294294
}
295295

296-
if (
297-
$width != UserAvatarFileProcessor::AVATAR_SIZE
298-
&& $width != UserAvatarFileProcessor::AVATAR_SIZE_2X
299-
) {
296+
if ((
297+
$width !== UserAvatarFileProcessor::AVATAR_SIZE
298+
&& $width !== UserAvatarFileProcessor::AVATAR_SIZE_2X
299+
) || (
300+
$height !== UserAvatarFileProcessor::AVATAR_SIZE
301+
&& $height !== UserAvatarFileProcessor::AVATAR_SIZE_2X
302+
)) {
300303
// resize avatar
301304
$adapter = ImageHandler::getInstance()->getAdapter();
302305

0 commit comments

Comments
 (0)