rolandstarke/laravel-thumbnail
最新稳定版本:v1.0.9
Composer 安装命令:
composer require rolandstarke/laravel-thumbnail
包简介
Laravel Thumbnail generator
关键字:
README 文档
README
<img src="{{ Storage::disk('public')->url('desert.jpg') }}"> <!-- <img src="/storage/desert.jpg"> --> <img src="{{ Thumbnail::src('desert.jpg', 'public')->smartcrop(200, 200)->url() }}"> <!-- <img src="/storage/jhf47.jpg?src=desert.jpg&smartcrop=200x200"> -->
Laravel package to resize images with specially formatted URLs.
- Generates the URL without touching the filesystem.
- Rendered thumbnails are stored and subsequent requests are directly served from your nginx/apache.
- The URL is signed to prevent malicious parameters.
Getting Started
Requirements
- GD Library or Imagick
- php >= 7.1.3
- laravel >= 5.5
Installation
To install the most recent version with composer run the following command.
composer require rolandstarke/laravel-thumbnail
Usage
<img src="{{ Thumbnail::src($path)->crop(64, 64)->url() }}" />
<?php
//load image from dir
\Thumbnail::src(public_path('images/example.jpeg'));
//load image from Storage::disk('local')
\Thumbnail::src('userimage.jpg', 'local' /* disk */);
//load image from website
\Thumbnail::src('https://picsum.photos/200');
?>
Checkout the docs for more examples.
Configuration
Publish the configuration file with the following command.
php artisan vendor:publish --tag=thumbnail-config
The configuration file is located at config/thumbnail.php. Read here what you can configure.
Commands
Deletes the generated thumbnails.
php artisan thumbnail:purge
Tests
php vendor/bin/phpunit
License
统计信息
- 总下载量: 126.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 52
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-07