Skip to content

Commit ae16562

Browse files
committed
modify CropController
1 parent ad81873 commit ae16562

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/controllers/CropController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ public function getCrop()
2727
*/
2828
public function getCropimage($overWrite = true)
2929
{
30-
$dataX = request('dataX');
31-
$dataY = request('dataY');
32-
$dataHeight = request('dataHeight');
33-
$dataWidth = request('dataWidth');
34-
$image_path = $this->lfm->setName(request('img'))->path('absolute');
30+
$image_name = request('img');
31+
$image_path = $this->lfm->setName($image_name)->path('absolute');
3532
$crop_path = $image_path;
3633

3734
if (! $overWrite) {
38-
$fileParts = explode('.', request('img'));
35+
$fileParts = explode('.', $image_name);
3936
$fileParts[count($fileParts) - 2] = $fileParts[count($fileParts) - 2] . '_cropped_' . time();
4037
$crop_path = $this->lfm->setName(implode('.', $fileParts))->path('absolute');
4138
}
4239

4340
event(new ImageIsCropping($image_path));
41+
42+
$crop_info = request()->only('dataWidth', 'dataHeight', 'dataX', 'dataY');
43+
4444
// crop image
4545
Image::make($image_path)
46-
->crop($dataWidth, $dataHeight, $dataX, $dataY)
46+
->crop(...array_values($crop_info))
4747
->save($crop_path);
4848

4949
// make new thumbnail
50-
$this->lfm->makeThumbnail($this->helper->getNameFromPath($image_path));
50+
$this->lfm->makeThumbnail($image_name);
5151

5252
event(new ImageWasCropped($image_path));
5353
}

0 commit comments

Comments
 (0)