fix crop issue with server avatar image upload
This commit is contained in:
parent
51064d95e3
commit
d7e30ce781
@ -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());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user