diff --git a/app/Http/Controllers/GalleryController.php b/app/Http/Controllers/GalleryController.php index 40d1f96..12b50bd 100644 --- a/app/Http/Controllers/GalleryController.php +++ b/app/Http/Controllers/GalleryController.php @@ -102,10 +102,6 @@ class GalleryController extends BaseController public function editGalleryView($name, Request $request) { $gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name); - /*session(['_old_input.name' => $gallery->name]); - session(['_old_input.description' => $gallery->description]); - session(['_old_input.date' => $gallery->gallery_create_time]); - session(['_old_input.url' => $gallery->url]);*/ return view("gallery.new", ["gallery" => $gallery]); } @@ -169,4 +165,16 @@ class GalleryController extends BaseController $gallery->saveOrFail(); return "OK"; } + + public function deleteImage($name, Request $request) { + $gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name); + $image = Image::query()->where("id", "=", $request->input("id"))->firstOrFail(); + if($image->gallery != $gallery->id) { + abort(400); + } + + Storage::disk($image->driver)->delete($image->path); + $image->delete(); + return "OK"; + } } diff --git a/app/Jobs/ResizeImage.php b/app/Jobs/ResizeImage.php index 408a754..4834331 100644 --- a/app/Jobs/ResizeImage.php +++ b/app/Jobs/ResizeImage.php @@ -61,7 +61,7 @@ class ResizeImage implements ShouldQueue $image = ImageResize::createFromString($file); $image->resizeToLongSide($this->size); - Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString()); + Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100)); } diff --git a/resources/views/gallery/images.blade.php b/resources/views/gallery/images.blade.php index 28f6f06..0009b28 100644 --- a/resources/views/gallery/images.blade.php +++ b/resources/views/gallery/images.blade.php @@ -38,7 +38,9 @@