]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/ImageRepo.php
Added mulit image-type compatability to manager & app and added scaled image selection
[bookstack] / app / Repos / ImageRepo.php
index 2699b9e971cb7a0d3b9a21f97b9bed03fcb4b1c3..0da243f7c8e2d9a4b3eb18aba3b931276302f06e 100644 (file)
@@ -52,15 +52,15 @@ class ImageRepo
 
 
     /**
-     * Get all images for the standard gallery view that's used for
-     * adding images to shared content such as pages.
-     * @param int $page
-     * @param int $pageSize
+     * Gets a load images paginated, filtered by image type.
+     * @param string $type
+     * @param int    $page
+     * @param int    $pageSize
      * @return array
      */
-    public function getAllGallery($page = 0, $pageSize = 24)
+    public function getPaginatedByType($type, $page = 0, $pageSize = 24)
     {
-        $images = $this->image->where('type', '=', 'gallery')
+        $images = $this->image->where('type', '=', strtolower($type))
             ->orderBy('created_at', 'desc')->skip($pageSize * $page)->take($pageSize + 1)->get();
         $hasMore = count($images) > $pageSize;
 
@@ -191,7 +191,7 @@ class ImageRepo
      * @param bool  $keepRatio
      * @return string
      */
-    private function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false)
+    public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false)
     {
         $thumbDirName = '/' . ($keepRatio ? 'scaled-' : 'thumbs-') . $width . '-' . $height . '/';
         $thumbFilePath = dirname($image->path) . $thumbDirName . basename($image->path);