File tree Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,12 @@ public function getDelete()
4242 return $ this ->success_response ;
4343 }
4444
45- File::delete ($ file_to_delete );
46-
47- if ($ this ->isProcessingImages ()) {
45+ if ($ this ->fileIsImage ($ file_to_delete )) {
4846 File::delete ($ thumb_to_delete );
4947 }
5048
49+ File::delete ($ file_to_delete );
50+
5151 event (new ImageWasDeleted ($ file_to_delete ));
5252
5353 return $ this ->success_response ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ private function getFilesWithInfo($path)
3434 $ file_created = filemtime ($ file );
3535 $ file_size = $ this ->humanFilesize (File::size ($ file ));
3636
37- if ($ this ->isProcessingImages ( )) {
37+ if ($ this ->fileIsImage ( $ file )) {
3838 $ file_type = File::mimeType ($ file );
3939 $ icon = 'fa-image ' ;
4040 } else {
Original file line number Diff line number Diff line change @@ -55,12 +55,12 @@ public function getRename()
5555 return $ this ->success_response ;
5656 }
5757
58- File::move ($ old_file , $ new_file );
59-
60- if ($ this ->isProcessingImages ()) {
58+ if ($ this ->fileIsImage ($ old_file )) {
6159 File::move (parent ::getThumbPath ($ old_name ), parent ::getThumbPath ($ new_name ));
6260 }
6361
62+ File::move ($ old_file , $ new_file );
63+
6464 event (new ImageWasRenamed ($ old_file , $ new_file ));
6565
6666 return $ this ->success_response ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ private function proceedSingleUpload($file)
5555
5656 event (new ImageIsUploading ($ new_file_path ));
5757 try {
58- if ($ this ->isProcessingImages ( )) {
58+ if ($ this ->fileIsImage ( $ file )) {
5959 Image::make ($ file ->getRealPath ())
6060 ->orientate () //Apply orientation from exif data
6161 ->save ($ new_file_path , 90 );
Original file line number Diff line number Diff line change 33namespace Unisharp \Laravelfilemanager \traits ;
44
55use Illuminate \Support \Facades \File ;
6+ use Symfony \Component \HttpFoundation \File \UploadedFile ;
67
78trait LfmHelpers
89{
@@ -226,6 +227,17 @@ public function directoryIsEmpty($directory_path)
226227 return count (File::allFiles ($ directory_path )) == 0 ;
227228 }
228229
230+ public function fileIsImage ($ file )
231+ {
232+ if ($ file instanceof UploadedFile) {
233+ $ mime_type = $ file ->getMimeType ();
234+ } else {
235+ $ mime_type = File::mimeType ($ file );
236+ }
237+
238+ return starts_with ($ mime_type , 'image ' );
239+ }
240+
229241
230242 /****************************
231243 *** Miscellaneouses ***
You can’t perform that action at this time.
0 commit comments