alcodo/powerimage
Composer 安装命令:
composer require alcodo/powerimage
包简介
Laravel Package to create a dynamic image handler
README 文档
README
Powerimage is a dynamic image handler for laravel. It uses the package thephpleague/glide for convert and spatie/image-optimizer for optimize the image.
After the installation you can request any image that you have uploaded in laravel. Example:
example.com/images/cat.jpg (Original)
example.com/images/cat_w=200&h=200.jpg (Convert)
The workflow is very simple. If image isn't found, laravel throw a exception. This package creates only one time this image. And on the next request the image will return form your webserver like nginx (fast response).
Structure:
{domain}/{path}/{fileimage name}_{resize parameter}.{extension}
Delimiter: _
Installation
Add packages:
composer require alcodo/powerimage:dev-master
Add powerimage handler in app/Exceptions/Handler.php:
public function render($request, Exception $exception) { PowerImage::check($request, $exception); return parent::render($request, $exception); }
And by the way you can inlcude or exclude paths that you want use powerimage example:
public function render($request, Exception $exception) { if (PowerImage::include ($request, ['/images/*', '/gallery/*'])) { PowerImage::check($request, $exception); } // or if (PowerImage::exclude($request, ['/user/*'])) { PowerImage::check($request, $exception); } return parent::render($request, $exception); }
Helper
Create powerimage path helper:
powerimage('images/video.png', ['w' => 200, 'h' => 350]); // outut 'images/video_w=200&h=350.png' // or direct in blade template <img class="img-fluid" src="{{ powerimage(Storage::url($image->filepath), ['w'=> 260, 'h' => 260]) }}" alt=""/>
License
The MIT License (MIT). Please see LICENSE for more information.
统计信息
- 总下载量: 18.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-11