Skip to content

Commit 1fd7984

Browse files
committed
resize method added
1 parent 1cd629b commit 1fd7984

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/HasUploader.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Plusemon\Uploader;
44

55
use Illuminate\Http\UploadedFile;
6+
use Intervention\Image\Facades\Image;
67

78
/**
89
* Name : Easy File Upload and View Helpers
@@ -238,4 +239,19 @@ public function deleteWith($column): bool
238239
{
239240
return $this->deleteWithFile($column);
240241
}
242+
243+
/**
244+
* Resizes current image based on given width and/or height. To contraint the resize command, pass an optional Closure callback as third parameter.
245+
*
246+
* @param int $width
247+
* @param int $height
248+
* @param \Closure $callback
249+
* @return \Plusemon\Uploader\HasUploader
250+
*/
251+
252+
public function resize($width = null, $height = null, $callback = null)
253+
{
254+
Image::make($this->uploaded_files[0])->resize($width, $height, $callback)->save();
255+
return $this;
256+
}
241257
}

0 commit comments

Comments
 (0)