Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resize image on upload #45

Open
sergeypoprovka opened this issue Dec 8, 2019 · 1 comment
Open

Can't resize image on upload #45

sergeypoprovka opened this issue Dec 8, 2019 · 1 comment

Comments

@sergeypoprovka
Copy link

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 :)

@tinkeshwar
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants