laravel-imageup icon indicating copy to clipboard operation
laravel-imageup copied to clipboard

Can't resize image on upload

Open sergeypoprovka opened this issue 5 years ago • 1 comments

Hi!

Trying to upload the image and resize it on upload.

Model (Profile):

`use HasImageUploads;

protected static $imageFields = [
    'avatar' => [
        [
            'width' => 300,
            'height' => 300,
            'crop' => false,
            'placeholder' => 'http://placehold.it/300x300',
            'rules' => 'image|max:2000',

        ]
    ]
];`

Controller: `public function uploadAvatar(Request $request, User $user){

    $request->validate([
        'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
    ]);

    $image = $request->file('image');

    $user->profile->uploadImage($image, 'avatar');

    return response()->json(['url'=>$user->profile->avatar], 200);
}`

But as a result I'm getting full-size image. What am I doing wrong? Any suggestions appreciated :)

Thanks in advance :)

sergeypoprovka avatar Dec 08 '19 17:12 sergeypoprovka

Hi, If you are looking for something like Laravel Imager Happy to help.

tinkeshwar avatar Mar 12 '21 08:03 tinkeshwar