rolandstarke / laravel-thumbnail
Laravel Thumbnail generator
Installs: 82 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 48
Watchers: 2
Forks: 16
Open Issues: 2
Requires
- php: >=7.1.3
- intervention/image: ^2.0
Requires (Dev)
- orchestra/testbench: ^4.0
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