use BookStack\Uploads\Image;
use BookStack\Uploads\ImageRepo;
use BookStack\Uploads\ImageService;
+use BookStack\Util\OutOfMemoryHandler;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
*/
public function update(Request $request, string $id)
{
- $this->validate($request, [
+ $data = $this->validate($request, [
'name' => ['required', 'min:2', 'string'],
]);
$this->checkImagePermission($image);
$this->checkOwnablePermission('image-update', $image);
- $image = $this->imageRepo->updateImageDetails($image, $request->all());
-
- $this->imageRepo->loadThumbs($image);
+ $image = $this->imageRepo->updateImageDetails($image, $data);
return view('pages.parts.image-manager-form', [
'image' => $image,
$dependantPages = $this->imageRepo->getPagesUsingImage($image);
}
- $this->imageRepo->loadThumbs($image);
+ $this->imageRepo->loadThumbs($image, false);
return view('pages.parts.image-manager-form', [
'image' => $image,
return response('');
}
+ /**
+ * Rebuild the thumbnails for the given image.
+ */
+ public function rebuildThumbnails(string $id)
+ {
+ $image = $this->imageRepo->getById($id);
+ $this->checkImagePermission($image);
+ $this->checkOwnablePermission('image-update', $image);
+
+ new OutOfMemoryHandler(function () {
+ return $this->jsonError(trans('errors.image_thumbnail_memory_limit'));
+ });
+
+ $this->imageRepo->loadThumbs($image, true);
+
+ return response(trans('components.image_rebuild_thumbs_success'));
+ }
+
/**
* Check related page permission and ensure type is drawio or gallery.
*/