]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/ImageRepo.php
Update Localization.php in Middleware with "no" tag for estimate.
[bookstack] / app / Uploads / ImageRepo.php
index 01b65f882698933b54f66ba51dcee3f885aaf5cc..a0855508594b7c336252bc4d9856c5eb01db20ec 100644 (file)
@@ -138,7 +138,7 @@ class ImageRepo
      */
     public function saveDrawing(string $base64Uri, int $uploadedTo): Image
     {
-        $name = 'Drawing-' . user()->getShortName(40) . '-' . strval(time()) . '.png';
+        $name = 'Drawing-' . strval(user()->id) . '-' . strval(time()) . '.png';
         return $this->imageService->saveNewFromBase64Uri($base64Uri, $name, 'drawio', $uploadedTo);
     }
 
@@ -185,7 +185,7 @@ class ImageRepo
      * Load thumbnails onto an image object.
      * @throws Exception
      */
-    protected function loadThumbs(Image $image)
+    public function loadThumbs(Image $image)
     {
         $image->thumbs = [
             'gallery' => $this->getThumbnail($image, 150, 150, false),
@@ -221,10 +221,18 @@ class ImageRepo
     }
 
     /**
-     * Get the validation rules for image files.
+     * Get the user visible pages using the given image.
      */
-    public function getImageValidationRules(): string
+    public function getPagesUsingImage(Image $image): array
     {
-        return 'image_extension|no_double_extension|mimes:jpeg,png,gif,bmp,webp,tiff';
+        $pages = Page::visible()
+            ->where('html', 'like', '%' . $image->url . '%')
+            ->get(['id', 'name', 'slug', 'book_id']);
+
+        foreach ($pages as $page) {
+            $page->url = $page->getUrl();
+        }
+
+        return $pages->all();
     }
 }