Skip to content

Commit 3333d01

Browse files
committed
Show original image where there isn’t thumb
1 parent 66d6ac1 commit 3333d01

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/traits/LfmHelpers.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ public function getFilesWithInfo($path)
285285
}
286286

287287
$thumb_path = $this->getThumbPath($file_name);
288-
$image_path = $this->getCurrentPath($file_name);
288+
$file_path = $this->getCurrentPath($file_name);
289289
if (File::exists($thumb_path)) {
290290
$thumb_url = $this->getThumbUrl($file_name) . '?timestamp=' . filemtime($thumb_path);
291-
} elseif (!$this->isImageToThumb($image_path)) {
292-
$thumb_url = $this->getFileUrl($file_name);
291+
} elseif ($this->isValidImageType($file_path)) {
292+
$thumb_url = $this->getFileUrl($file_name) . '?timestamp=' . filemtime($file_path);
293293
} else {
294294
$thumb_url = null;
295295
}
@@ -342,6 +342,18 @@ public function isImageToThumb($file)
342342
return true;
343343
}
344344

345+
public function isValidImageType($file)
346+
{
347+
$mine_type = $this->getFileType($file);
348+
$valid_image_mimetypes = config('lfm.valid_image_mimetypes');
349+
350+
if (in_array($mine_type, $valid_image_mimetypes)) {
351+
return true;
352+
}
353+
354+
return false;
355+
}
356+
345357
public function getFileType($file)
346358
{
347359
if ($file instanceof UploadedFile) {

0 commit comments

Comments
 (0)