diff --git a/app/Http/Controllers/Api/UserAvatarController.php b/app/Http/Controllers/Api/UserAvatarController.php index f685d5634..5663f16a7 100644 --- a/app/Http/Controllers/Api/UserAvatarController.php +++ b/app/Http/Controllers/Api/UserAvatarController.php @@ -38,8 +38,22 @@ public function store() $constraint->aspectRatio(); }); + $imgResized = Image::make($file); + + $imgResized->resize(null, 80, function ($constraint) { + $constraint->aspectRatio(); + }); + //detach method is the key! Hours to find it... :/ $resource = $img->stream()->detach(); + $resourceResized = $imgResized->stream()->detach(); + + $resizedImageName = 'avatars/' . auth()->user()->getAuthIdentifier() . '/resized/80/' . $file->getClientOriginalName(); + + Storage::disk('s3')->put( + $resizedImageName, + $resourceResized + ); Storage::disk('s3')->put( $imageName,