Added mulit image-type compatability to manager & app and added scaled image selection

This commit is contained in:
Dan Brown
2015-12-08 22:04:59 +00:00
parent 32d5b12d27
commit a3188d349c
9 changed files with 78 additions and 25 deletions

View 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);