Skip to content

Commit ac97c73

Browse files
authored
Merge pull request #1103 from ANDRU19/master
Added ability to set thumb size under folder category
2 parents 313357c + 1cb953c commit ac97c73

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Lfm.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@ public function availableMimeTypes()
162162
{
163163
return $this->config->get('lfm.folder_categories.' . $this->currentLfmType() . '.valid_mime');
164164
}
165+
166+
public function shouldCreateCategoryThumb()
167+
{
168+
return $this->config->get('lfm.folder_categories.' . $this->currentLfmType() . '.thumb');
169+
}
170+
171+
public function categoryThumbWidth()
172+
{
173+
return $this->config->get('lfm.folder_categories.' . $this->currentLfmType() . '.thumb_width');
174+
}
175+
176+
public function categoryThumbHeight()
177+
{
178+
return $this->config->get('lfm.folder_categories.' . $this->currentLfmType() . '.thumb_height');
179+
}
165180

166181
public function maxUploadSize()
167182
{

src/LfmPath.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,10 @@ public function generateThumbnail($file_name)
315315

316316
// generate cropped image content
317317
$this->setName($file_name)->thumb(true);
318+
$thumbWidth = $this->helper->shouldCreateCategoryThumb() && $this->helper->categoryThumbWidth() ? $this->helper->categoryThumbWidth() : config('lfm.thumb_img_width', 200);
319+
$thumbHeight = $this->helper->shouldCreateCategoryThumb() && $this->helper->categoryThumbHeight() ? $this->helper->categoryThumbHeight() : config('lfm.thumb_img_height', 200);
318320
$image = Image::make($original_image->get())
319-
->fit(config('lfm.thumb_img_width', 200), config('lfm.thumb_img_height', 200));
321+
->fit($thumbWidth, $thumbHeight);
320322

321323
$this->storage->put($image->stream()->detach(), 'public');
322324
}

src/config/lfm.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
'folder_name' => 'files',
5151
'startup_view' => 'list',
5252
'max_size' => 50000, // size in KB
53+
'thumb' => true,
54+
'thumb_width' => 80,
55+
'thumb_height' => 80,
5356
'valid_mime' => [
5457
'image/jpeg',
5558
'image/pjpeg',
@@ -63,6 +66,9 @@
6366
'folder_name' => 'photos',
6467
'startup_view' => 'grid',
6568
'max_size' => 50000, // size in KB
69+
'thumb' => true,
70+
'thumb_width' => 80,
71+
'thumb_height' => 80,
6672
'valid_mime' => [
6773
'image/jpeg',
6874
'image/pjpeg',

0 commit comments

Comments
 (0)