elsayednofal / imagemanager
ImageManager 的包
3.0
2020-09-30 14:49 UTC
README
一行代码即可管理上传和选择图片的图片管理器
安装
- 运行此命令
composer require elsayednofal/imagemanager:3.0
- 将服务提供者添加到您的应用配置文件 config/app.php 中
Elsayednofal\Imagemanager\ImageManagerServiceProvider::class
- 在别名中添加以下行
'ImageManager' => Elsayednofal\Imagemanager\Controllers\MediaController::class,
- 运行命令
php artisan vendor:publish
- 运行命令
php artisan migrate
配置
- 从文件 config/image-manager 编辑配置
- 您可以从 backend/image-manager 更改视图
用法
1- 在关闭之前添加 {!! ImageManager::loadAssets() !!}
,2- 之后添加 {!! ImageManager::loadModal() !!}
选择器
- 在您的 blade 中添加一行,以在表单中添加上传器
//images[] is the variable you will recieve the ids of selected or uploaded images in {!! ImageManager::selector('images[]') !!}
- 在某些情况下,例如更新,您想显示旧选定的图片,因此您可以像下面这样传递 ID 作为第二个参数
//images[] is the variable you will recieve the ids of selected or uploaded images in {!! ImageManager::selector('images[]',[10,15,17])?>
- 在某些情况下,您想让用户只选择一张图片
//images[] is the variable you will recieve the ids of selected or uploaded images in // [] represent selected ids // false => means only one image can be set {!! ImageManager::selector('images[]',[],false)?>
如何获取选中或上传图片的值?ImageManger::selector() 注入包含选中图片 ID 的隐藏输入值
- 检索图片(显示图片)
ImageManager::getImagePath($id,$size='') id image id size can be '' for orginal size , 'thumb' for thumbnial and 'small' for small image <img src="{{ImageManager::getImagePath($activity->mainImage->image_id,'small')}}" />
单个图片上传器
-
单个文件上传
{!! ImageManager::ImageUploader(['name'=>'logo'])!!}
-
上传和更新旧图片
{!! ImageManager::ImageUploader(['name'=>'logo','image'=>$logo])!!}
-
上传的文件必须有宽度和高度
{!! ImageManager::ImageUploader(['name'=>'logo','image'=>$logo,'width'=>160,'height'=>160])!!}
支持
如有任何问题,请联系我: elsayed_nofal@ymail.com