kunalkurhader / thumbr
一个简单的PHP包,用于动态创建缩略图。
2.7
2021-12-14 05:19 UTC
Requires
- php: >=5.3.3
- laravel/framework: >=5.4
README
这是一个Laravel包,您可以在动态创建图像缩略图并重复使用它。
安装
使用Composer安装thumbr
composer require kunalkurhader/thumbr
编辑config/app.php文件,并在providers数组下添加以下行
Kurhades\Thumbr\ThumbrServiceProvider::class,
现在,在修改了config/app.php之后,让我们清除配置缓存
php artisan config:cache
为了复制配置文件,让我们使用以下命令发布
php artisan vendor:publish --provider="Kurhades\Thumbr\ThumbrServiceProvider"
配置选项
配置文件将位于config文件夹中,命名为thumbr.php
<?php return [ //folder name where we will be storing thumbs images inside storage/app/public 'folder_name' => 'thumbs', //mention the disk where we will be storing the file Ex : Storage, s3, azure etc 'disk' => 'public', //if we are loading image from url local, s3, azure etc then its `true` else `false` 'is_image_url' => false, ];
如何使用?
//in blade file in case we are loading file from URL /* * Parameters : * 1. source Image (with path or URL) * 2. thumb image name Image * 3. width of the image * 4. height of the image */ <img src="{{\Kurhades\Thumbr\Thumbr::CreateThumb("https://DOMAINURL/image.jpg", "ocean23.jpeg", 100, 80)}}"> //in blade file in case we are loading file from storage <img src="{{\Kurhades\Thumbr\Thumbr::CreateThumb("folder/path/ocean.jpeg", "ocean23.jpeg", 100, 80)}}">