File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -52,14 +52,27 @@ public function getResize()
5252 ->with ('ratio ' , $ ratio );
5353 }
5454
55- public function performResize ()
55+ public function performResize ($ overWrite = true )
5656 {
57+ $ image_name = request ('img ' );
5758 $ image_path = $ this ->lfm ->setName (request ('img ' ))->path ('absolute ' );
59+ $ resize_path = $ image_path ;
60+
61+ if (! $ overWrite ) {
62+ $ fileParts = explode ('. ' , $ image_name );
63+ $ fileParts [count ($ fileParts ) - 2 ] = $ fileParts [count ($ fileParts ) - 2 ] . '_resized_ ' . time ();
64+ $ resize_path = $ this ->lfm ->setName (implode ('. ' , $ fileParts ))->path ('absolute ' );
65+ }
5866
5967 event (new ImageIsResizing ($ image_path ));
60- Image::make ($ image_path )->resize (request ('dataWidth ' ), request ('dataHeight ' ))->save ();
68+ Image::make ($ image_path )->resize (request ('dataWidth ' ), request ('dataHeight ' ))->save ($ resize_path );
6169 event (new ImageWasResized ($ image_path ));
6270
6371 return parent ::$ success_response ;
6472 }
73+
74+ public function performResizeNew ()
75+ {
76+ $ this ->performResize (false );
77+ }
6578}
Original file line number Diff line number Diff line change @@ -364,7 +364,10 @@ public static function routes()
364364 'uses ' => 'ResizeController@performResize ' ,
365365 'as ' => 'performResize ' ,
366366 ]);
367-
367+ Route::get ('/doresizenew ' , [
368+ 'uses ' => 'ResizeController@performResizeNew ' ,
369+ 'as ' => 'performResizeNew ' ,
370+ ]);
368371 // download
369372 Route::get ('/download ' , [
370373 'uses ' => 'DownloadController@getDownload ' ,
Original file line number Diff line number Diff line change 6767 'btn-cancel ' => 'Cancel ' ,
6868 'btn-confirm ' => 'Confirm ' ,
6969 'btn-resize ' => 'Resize ' ,
70+ 'btn-resize-copy ' => 'Copy & Resize ' ,
7071 'btn-open ' => 'Open Folder ' ,
7172
7273 'resize-ratio ' => 'Ratio: ' ,
Original file line number Diff line number Diff line change 5959 </table >
6060 <div class =" d-flex mb-3" >
6161 <button class =" btn btn-secondary w-50 mr-1" onclick =" loadItems()" >{{ trans (' laravel-filemanager::lfm.btn-cancel' ) } } </button >
62+ <button class =" btn btn-warning w-50 mr-1" onclick =" doResizeNew()" >{{ trans (' laravel-filemanager::lfm.btn-resize-copy' ) } } </button >
6263 <button class =" btn btn-primary w-50" onclick =" doResize()" >{{ trans (' laravel-filemanager::lfm.btn-resize' ) } } </button >
6364 </div >
6465
@@ -120,4 +121,12 @@ function doResize() {
120121 dataWidth: $ (" #width" ).val ()
121122 }).done (loadItems);
122123 }
124+
125+ function doResizeNew () {
126+ performLfmRequest (' doresizenew' , {
127+ img: $ (" #img" ).val (),
128+ dataHeight: $ (" #height" ).val (),
129+ dataWidth: $ (" #width" ).val ()
130+ }).done (loadItems);
131+ }
123132 </script >
You can’t perform that action at this time.
0 commit comments