Skip to content

Commit 59614a1

Browse files
committed
show original gif and svg file (#233 & #226)
1 parent bd22fa6 commit 59614a1

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/config/lfm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
'image/gif',
101101
'application/pdf',
102102
'text/plain',
103+
'image/svg+xml',
103104
],
104105

105106
/*

src/controllers/UploadController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private function proceedSingleUpload($file)
5454

5555
event(new ImageIsUploading($new_file_path));
5656
try {
57-
if ($this->fileIsImage($file)) {
57+
if ($this->fileIsImage($file) && $this->isImageToThumb($file)) {
5858
Image::make($file->getRealPath())
5959
->orientate() //Apply orientation from exif data
6060
->save($new_file_path, 90);

src/traits/LfmHelpers.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,33 @@ public function directoryIsEmpty($directory_path)
319319
}
320320

321321
public function fileIsImage($file)
322+
{
323+
$mime_type = $this->getFileType($file);
324+
325+
return starts_with($mime_type, 'image');
326+
}
327+
328+
public function isImageToThumb($file)
329+
{
330+
$mine_type = $this->getFileType($file);
331+
$noThumbType = ['image/gif', 'image/svg+xml'];
332+
333+
if (in_array($mine_type, $noThumbType)) {
334+
return false;
335+
}
336+
337+
return true;
338+
}
339+
340+
public function getFileType($file)
322341
{
323342
if ($file instanceof UploadedFile) {
324343
$mime_type = $file->getMimeType();
325344
} else {
326345
$mime_type = File::mimeType($file);
327346
}
328347

329-
return starts_with($mime_type, 'image');
348+
return $mime_type;
330349
}
331350

332351
public function sortFilesAndDirectories($arr_items, $sort_type)

0 commit comments

Comments
 (0)