flipbox/image-controller
Composer 安装命令:
composer require flipbox/image-controller
包简介
Image controller for laravel
README 文档
README
Controller your images for client request with size, quality, and extenstion with easy way. You no longer need to create an image with multiple sizes, this package is already handling request images with size needed,
Features
- Dynamic images request file
- Controller image size
- Controller image quality
- Controller image extension
- Cache image
Required
- php >= 5.6.4
- laravel/framework 5.3.*
- intervention/image ^2.3
- intervention/imagecache ^2.3
Installation
Require this package with composer:
composer require flipbox/image-controller
Add the ServiceProvider to the providers array in config/app.php
Flipbox\ImageController\ImageControllerServiceProvider::class,
Add the facade of this package to the $aliases array config/app.php
'ImageController' => Flipbox\ImageController\Facade::class
Copy the package resource to your application with the publish command:
php artisan vendor:publish
your image ready to control :-)
Using package
To avoid clashed request, we suggest you to add a little code to the end of your .htaccess file in public laravel folder
RewriteRule .*\.(jpg|png|gif|tif|bmp)$ index.php [NC,L]
create folder images to your public folder (however you can change name of folder in config file), and put image to that folder, for example you put image with file name a photo.jpg, and you can access your photo as usual http://localhost/images/photo.jpg.
Request with size
Now you can request image with specify size (thumbnail,small,medium,large)
http://localhost/images/photo.jpg?size=thumbnail default width 100px
http://localhost/images/photo.jpg?size=small default width 240px
http://localhost/images/photo.jpg?size=medium default width 500px
http://localhost/images/photo.jpg?size=large default width 1024px
Request with specify width or height
Also you can request image with specify width or height or event both
http://localhost/images/photo.jpg?width=320 auto height
http://localhost/images/photo.jpg?height=320 auto width
http://localhost/images/photo.jpg?width=100&height=320 fixed width and height
Request with another extension
Real file extension will be ignored, now you can access your images file with extensions that defined in config or even with no extension
http://localhost/images/photo valid by default
http://localhost/images/photo.jpg valid by default
http://localhost/images/photo.png valid by default
http://localhost/images/photo.gif valid by default
Uploaded file
We provide uploader file that make upload file very easy. First parameter is UploadedFile or Base64 Encoding, and second parameter is directory/prefix.
ImageController::upload($request->file, 'profile');
this method will be return string of generated filename str_random(34)
Model Assesor
Add model accesor to generate image link.
/**
* Get ProfilePicture.
*
* @param string $value
* @return string
*/
public function getProfilePictureAttribute($value)
{
return ImageController::generateImageUrl($value, 'small');
}
ToDo
- Add Watermark
- Test
flipbox/image-controller 适用场景与选型建议
flipbox/image-controller 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 615 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 flipbox/image-controller 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flipbox/image-controller 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 615
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-26