Skip to content

Latest commit

 

History

History
87 lines (56 loc) · 2.43 KB

README.md

File metadata and controls

87 lines (56 loc) · 2.43 KB

Laravel Thumbnail

Build PHP Version Latest Stable Version LICENSE

image image resized

<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

MIT