使用 Intervention image 为 Laravel eloquent 模型自动上传、调整大小和裁剪图像和文件
使用 Intervention image 为 Laravel eloquent 模型自动上传、调整大小和裁剪图像和文件
qcod/laravel-imageup 是一个 trait,它为图像功能提供自动上传、调整大小和裁剪,并提供大量自定义选项。模型
> Make sure to run `php artisan storage:link` to see the images from public storage disk
That's it, with above setup when ever you hit store method with post request and if `cover` or `avatar` named file is present on request() it will be auto uploaded.
## Upload Field options
ImageUp gives you tons of customization on how the upload and resize will be handled from defined field options, following are the things you can customize:
php [ // 上传后调整图片宽度 'width' => 200,
// 上传后调整图片高度
'height' => 100,
// 设置为 true 可裁剪图片,并可传递 arr [x,y] 坐标进行裁剪。
'crop' => true,
// 要上传到的磁盘,默认为 config('imageup.upload_disk')
'disk' => 'public',
// 上述磁盘上的文件夹路径,默认为 config('imageup.upload_directory')
'path' => 'avatars',
// 如果图片字段为空,则使用占位图
'placeholder' => '/images/avatar-placehold暂无开放 Issues,或尚未同步最近议题。