X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/cb832a2c10984b91bb7dbf4df7874bbb2e7dcbef..refs/pull/1584/head:/app/Http/Controllers/BookshelfController.php diff --git a/app/Http/Controllers/BookshelfController.php b/app/Http/Controllers/BookshelfController.php index e63cfd1d5..bcf2e12df 100644 --- a/app/Http/Controllers/BookshelfController.php +++ b/app/Http/Controllers/BookshelfController.php @@ -86,8 +86,9 @@ class BookshelfController extends Controller /** * Store a newly created bookshelf in storage. - * @param Request $request + * @param Request $request * @return Response + * @throws \BookStack\Exceptions\ImageUploadException */ public function store(Request $request) { @@ -123,6 +124,7 @@ class BookshelfController extends Controller $this->entityContextManager->setShelfContext($shelf->id); $this->setPageTitle($shelf->getShortName()); + return view('shelves.show', [ 'shelf' => $shelf, 'books' => $books, @@ -284,10 +286,18 @@ class BookshelfController extends Controller $this->entityRepo->updateShelfBooks($shelf, $request->get('books', '')); // Update the cover image if in request - if ($request->has('image') && userCan('image-create-all')) { - $image = $this->imageRepo->saveNew($request->file('image'), 'cover', $shelf->id); + if ($request->has('image')) { + $newImage = $request->file('image'); + $this->imageRepo->destroyImage($shelf->cover); + $image = $this->imageRepo->saveNew($newImage, 'cover_shelf', $shelf->id, 512, 512, true); $shelf->image_id = $image->id; $shelf->save(); } + + if ($request->has('image_reset')) { + $this->imageRepo->destroyImage($shelf->cover); + $shelf->image_id = 0; + $shelf->save(); + } } }