<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.
- GD Library or Imagick
- php >= 7.1.3
- laravel >= 5.5
To install the most recent version with composer run the following command.
composer require rolandstarke/laravel-thumbnail
<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.
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.
Deletes the generated thumbnails.
php artisan thumbnail:purge
php vendor/bin/phpunit