use BookStack\Page;
use BookStack\Services\ImageService;
use BookStack\Services\PermissionService;
+use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Setting;
use Symfony\Component\HttpFoundation\File\UploadedFile;
protected $image;
protected $imageService;
- protected $restictionService;
+ protected $restrictionService;
protected $page;
/**
{
$this->image = $image;
$this->imageService = $imageService;
- $this->restictionService = $permissionService;
+ $this->restrictionService = $permissionService;
$this->page = $page;
}
*/
private function returnPaginated($query, $page = 0, $pageSize = 24)
{
- $images = $this->restictionService->filterRelatedPages($query, 'images', 'uploaded_to');
+ $images = $this->restrictionService->filterRelatedPages($query, 'images', 'uploaded_to');
$images = $images->orderBy('created_at', 'desc')->skip($pageSize * $page)->take($pageSize + 1)->get();
$hasMore = count($images) > $pageSize;
*/
public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false)
{
- return $this->imageService->getThumbnail($image, $width, $height, $keepRatio);
+ try {
+ return $this->imageService->getThumbnail($image, $width, $height, $keepRatio);
+ } catch (FileNotFoundException $exception) {
+ $image->delete();
+ return [];
+ }
}