Skip to content

Commit bb54207

Browse files
authored
Merge pull request #23 from nauvalazhar/myfix
Added auto-generate for missing thumbnail
2 parents 29ca939 + 445c67f commit bb54207

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

src/Controller/MidiaController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public function index($limit) {
7979
$_files = [];
8080
foreach($exec as $i => $item) {
8181
if(!is_dir($this->directory . '/' . $item)) {
82+
$this->_resize($item);
83+
8284
$_files[$i]['fullname'] = $item;
8385
$_files[$i]['name'] = pathinfo($item, PATHINFO_FILENAME);
8486
$_files[$i]['url'] = $this->url($this->directory_name . '/' . $item);
@@ -168,9 +170,14 @@ public function _resize($fileName) {
168170
if(!is_dir($this->directory . '/' . $thumb_folder))
169171
mkdir($this->directory . '/' . $thumb_folder);
170172

171-
$image = Image::make($this->directory . '/' . $fileName);
173+
$file = $this->directory . '/' . $fileName;
174+
$thumb_file = $this->directory . '/' . $thumb_folder . '/' . $fileName;
175+
176+
if(file_exists($thumb_file)) continue;
177+
178+
$image = Image::make($file);
172179
$image->fit($thumb);
173-
$image->save($this->directory . '/' . $thumb_folder . '/' . $fileName);
180+
$image->save($thumb_file);
174181
}
175182
}
176183

0 commit comments

Comments
 (0)