Skip to content

Commit 22b0d63

Browse files
committed
more proper image size support in getter.
1 parent 2f11e74 commit 22b0d63

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/FileApi.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
class FileApi
1111
{
12+
const SIZE_ORIGINAL = null;
13+
const SIZE_LARGE = 'L';
14+
const SIZE_MEDIUM = 'M';
15+
const SIZE_SMALL = 'S';
16+
1217
protected $basepath;
1318
protected $default_sizes = ['S' => '96x96', 'M' => '256x256', 'L' => '480x480'];
1419
protected $thumb_sizes = null;
@@ -28,7 +33,7 @@ public function __construct($basepath = DIRECTORY_SEPARATOR)
2833
$this->basepath = $basepath;
2934
}
3035

31-
public function get($filename, $size = null)
36+
public function get($filename, $size = self::SIZE_LARGE)
3237
{
3338
if (empty($filename)) {
3439
return '';
@@ -40,13 +45,12 @@ public function get($filename, $size = null)
4045
if (empty($filename)) {
4146
return '';
4247
}
43-
44-
if (empty($size) && \Storage::exists($this->basepath . $file[0] . '_L.' . $file[1])) {
45-
$file_path = $this->basepath . $file[0] . '_L.' . $file[1];
46-
} elseif (\Storage::exists($this->basepath . $file[0] . '_' . $size . '.' . $file[1])) {
48+
49+
$file_path = $this->basepath . $filename;
50+
51+
if ($size != self::SIZE_ORIGINAL
52+
&& \Storage::exists($this->basepath . $file[0] . '_' . $size . '.' . $file[1])) {
4753
$file_path = $this->basepath . $file[0] . '_' . $size . '.' . $file[1];
48-
} else {
49-
$file_path = $this->basepath . $filename;
5054
}
5155

5256
if (\Config::get('filesystems.default') == 's3') {

0 commit comments

Comments
 (0)