@@ -29,24 +29,36 @@ public function getCrop()
2929 /**
3030 * Crop the image (called via ajax)
3131 */
32- public function getCropimage ()
32+ public function getCropimage ($ overWrite = true )
3333 {
3434 $ dataX = request ('dataX ' );
3535 $ dataY = request ('dataY ' );
3636 $ dataHeight = request ('dataHeight ' );
3737 $ dataWidth = request ('dataWidth ' );
3838 $ image_path = parent ::getCurrentPath (request ('img ' ));
39+ $ crop_path = $ image_path ;
40+
41+ if (!$ overWrite ) {
42+ $ fileParts = explode ('. ' , request ('img ' ));
43+ $ fileParts [count ($ fileParts ) - 2 ] = $ fileParts [count ($ fileParts ) - 2 ] . '_cropped_ ' . time ();
44+ $ crop_path = parent ::getCurrentPath (implode ('. ' , $ fileParts ));
45+ }
3946
4047 event (new ImageIsCropping ($ image_path ));
4148 // crop image
4249 Image::make ($ image_path )
4350 ->crop ($ dataWidth , $ dataHeight , $ dataX , $ dataY )
44- ->save ($ image_path );
51+ ->save ($ crop_path );
4552
4653 // make new thumbnail
47- Image::make ($ image_path )
54+ Image::make ($ crop_path )
4855 ->fit (config ('lfm.thumb_img_width ' , 200 ), config ('lfm.thumb_img_height ' , 200 ))
49- ->save (parent ::getThumbPath (parent ::getName ($ image_path )));
56+ ->save (parent ::getThumbPath (parent ::getName ($ crop_path )));
5057 event (new ImageWasCropped ($ image_path ));
5158 }
59+
60+ public function getNewCropimage (){
61+
62+ $ this ->getCropimage (false );
63+ }
5264}
0 commit comments