fix crop issue with server avatar image upload

This commit is contained in:
Joseph D'Souza 2026-02-11 12:59:40 +01:00
parent 51064d95e3
commit d7e30ce781

View File

@ -11,9 +11,8 @@ use Intervention\Image\ImageManager;
class UserAvatarManager class UserAvatarManager
{ {
const AVATAR_WIDTH = 160; const AVATAR_WIDTH = 500;
const AVATAR_HEIGHT = 500;
const AVATAR_HEIGHT = 160;
/** /**
* @var User * @var User
@ -119,9 +118,11 @@ class UserAvatarManager
$image->crop($size, $size, (int) $points['x1'], (int) $points['y1']) $image->crop($size, $size, (int) $points['x1'], (int) $points['y1'])
->resize(self::AVATAR_WIDTH, self::AVATAR_HEIGHT); ->resize(self::AVATAR_WIDTH, self::AVATAR_HEIGHT);
} else { } else {
// If crop points are not provided, we will just crop // If crop points are not provided, we will just resize maintaining aspect ratio.
// provided image to specified width and height. $image->resize(self::AVATAR_WIDTH, self::AVATAR_HEIGHT, function ($constraint) {
$image->crop(self::AVATAR_WIDTH, self::AVATAR_HEIGHT); $constraint->aspectRatio();
$constraint->upsize();
});
} }
$fileName = $file->hashName($this->getDestinationDirectory()); $fileName = $file->hashName($this->getDestinationDirectory());