+ /**
+ * Update image details
+ * @param integer $id
+ * @param Request $request
+ * @return \Illuminate\Http\JsonResponse
+ * @throws ImageUploadException
+ * @throws \Exception
+ */
+ public function update($id, Request $request)
+ {
+ $this->validate($request, [
+ 'name' => 'required|min:2|string'
+ ]);
+
+ $image = $this->imageRepo->getById($id);
+ $this->checkOwnablePermission('image-update', $image);
+
+ $image = $this->imageRepo->updateImageDetails($image, $request->all());
+ return response()->json($image);
+ }
+
+ /**
+ * Show the usage of an image on pages.
+ * @param \BookStack\Entities\Repos\EntityRepo $entityRepo
+ * @param $id
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function usage(EntityRepo $entityRepo, $id)
+ {
+ $image = $this->imageRepo->getById($id);
+ $pageSearch = $entityRepo->searchForImage($image->url);
+ return response()->json($pageSearch);
+ }
+
+ /**
+ * Deletes an image and all thumbnail/image files
+ * @param int $id
+ * @return \Illuminate\Http\JsonResponse
+ * @throws \Exception
+ */
+ public function destroy($id)
+ {
+ $image = $this->imageRepo->getById($id);
+ $this->checkOwnablePermission('image-delete', $image);
+
+ $this->imageRepo->destroyImage($image);
+ return response()->json(trans('components.images_deleted'));
+ }