BookStack\Http\Controllers\ImageController::destroy PHP Method

destroy() public method

Deletes an image and all thumbnail/image files
public destroy ( PageRepo $pageRepo, Illuminate\Http\Request $request, integer $id ) : Illuminate\Http\JsonResponse
$pageRepo BookStack\Repos\PageRepo
$request Illuminate\Http\Request
$id integer
return Illuminate\Http\JsonResponse
    public function destroy(PageRepo $pageRepo, Request $request, $id)
    {
        $image = $this->imageRepo->getById($id);
        $this->checkOwnablePermission('image-delete', $image);
        // Check if this image is used on any pages
        $isForced = $request->has('force') && $request->get('force') === 'true' || $request->get('force') === true;
        if (!$isForced) {
            $pageSearch = $pageRepo->searchForImage($image->url);
            if ($pageSearch !== false) {
                return response()->json($pageSearch, 400);
            }
        }
        $this->imageRepo->destroyImage($image);
        return response()->json('Image Deleted');
    }