From bbabc452bd09ebfabffd4f31ddbeb8fbace586a2 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 1 Nov 2016 10:35:36 +0100 Subject: [PATCH] Improved update of old/imported avatars --- .../files/lib/system/worker/UserRebuildDataWorker.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index 2199028987..f15cad81cd 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -97,7 +97,7 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker { } WCF::getDB()->commitTransaction(); - // update old avatars + // update old/imported avatars $avatarList = new UserAvatarList(); $avatarList->getConditionBuilder()->add('user_avatar.userID IN (?)', [$userIDs]); $avatarList->getConditionBuilder()->add('(user_avatar.width <> ? OR user_avatar.height <> ?)', [UserAvatar::AVATAR_SIZE, UserAvatar::AVATAR_SIZE]); @@ -106,6 +106,7 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker { $width = $avatar->width; $height = $avatar->height; if ($width != $height) { + // make avatar quadratic $width = $height = min($width, $height, UserAvatar::AVATAR_SIZE); $adapter = ImageHandler::getInstance()->getAdapter(); $adapter->loadFile($avatar->getLocation()); @@ -113,7 +114,8 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker { $adapter->writeImage($thumbnail, $avatar->getLocation()); } - if ($width < UserAvatar::AVATAR_SIZE || $height < UserAvatar::AVATAR_SIZE) { + if ($width != UserAvatar::AVATAR_SIZE || $height != UserAvatar::AVATAR_SIZE) { + // resize avatar $adapter = ImageHandler::getInstance()->getAdapter(); $adapter->loadFile($avatar->getLocation()); $adapter->resize(0, 0, $width, $height, UserAvatar::AVATAR_SIZE, UserAvatar::AVATAR_SIZE); -- 2.20.1