- allow empty input

- allow svg avatar
This commit is contained in:
Peter Papp
2021-05-06 10:08:58 +02:00
parent 86b6844d62
commit bd881da856
4 changed files with 25 additions and 15 deletions

View File

@@ -290,14 +290,20 @@ function store_avatar($request, $name)
// Store avatar
$image_path = Str::random(16) . '-' . $image->getClientOriginalName();
// Create intervention image
$img = Image::make($image->getRealPath());
if (in_array($image->getClientMimeType(), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
// Create intervention image
$img = Image::make($image->getRealPath());
// Generate thumbnail
$img->fit('150', '150')->stream();
// Generate thumbnail
$img->fit('150', '150')->stream();
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
}
if ($image->getClientMimeType() === 'image/svg+xml') {
Storage::putFileAs('avatars', $image, $image_path);
}
// Return path to image
return "avatars/$image_path";