Skip to content

Commit bbfe642

Browse files
committed
Fix resizing not working on Windows
1 parent c906601 commit bbfe642

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

src/controllers/ResizeController.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,16 @@ public function getResize()
5555

5656
public function performResize()
5757
{
58-
$img = request('img');
5958
$dataX = request('dataX');
6059
$dataY = request('dataY');
6160
$height = request('dataHeight');
6261
$width = request('dataWidth');
63-
$image_path = public_path() . $img;
62+
$image_path = parent::getCurrentPath(request('img'));
6463

65-
try {
66-
event(new ImageIsResizing($image_path));
67-
Image::make($image_path)->resize($width, $height)->save();
68-
event(new ImageWasResized($image_path));
69-
return parent::$success_response;
70-
} catch (Exception $e) {
71-
return "width : " . $width . " height: " . $height;
72-
return $e;
73-
}
64+
event(new ImageIsResizing($image_path));
65+
Image::make($image_path)->resize($width, $height)->save();
66+
event(new ImageWasResized($image_path));
67+
68+
return parent::$success_response;
7469
}
7570
}

src/views/resize.blade.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<button class="btn btn-primary" onclick="doResize()">{{ trans('laravel-filemanager::lfm.btn-resize') }}</button>
4242
<button class="btn btn-info" onclick="loadItems()">{{ trans('laravel-filemanager::lfm.btn-cancel') }}</button>
4343

44+
<input type="hidden" id="img" name="img" value="{{ $img->name }}">
4445
<input type="hidden" name="ratio" value="{{ $ratio }}"><br>
4546
<input type="hidden" name="scaled" value="{{ $scaled }}"><br>
4647
<input type="hidden" id="original_height" name="original_height" value="{{ $original_height }}"><br>
@@ -70,25 +71,12 @@
7071
});
7172
7273
function doResize() {
73-
$.ajax({
74-
type: "GET",
75-
dataType: "text",
76-
url: "{{ route('unisharp.lfm.performResize') }}",
77-
data: {
78-
img: '{{ parse_url($img->url, PHP_URL_PATH) }}',
79-
working_dir: $("#working_dir").val(),
80-
dataX: $("#dataX").val(),
81-
dataY: $("#dataY").val(),
82-
dataHeight: $("#height").val(),
83-
dataWidth: $("#width").val()
84-
},
85-
cache: false
86-
}).done(function (data) {
87-
if (data == "OK") {
88-
loadItems();
89-
} else {
90-
notify(data);
91-
}
92-
});
74+
performLfmRequest('doresize', {
75+
img: $("#img").val(),
76+
dataX: $("#dataX").val(),
77+
dataY: $("#dataY").val(),
78+
dataHeight: $("#height").val(),
79+
dataWidth: $("#width").val()
80+
}).done(loadItems);
9381
}
9482
</script>

0 commit comments

Comments
 (0)