Package Data | |
---|---|
Maintainer Username: | amostajo |
Maintainer Contact: | amostajo@gmail.com (Alejandro Mostajo) |
Package Create Date: | 2015-07-02 |
Package Last Update: | 2017-01-09 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-08 03:23:01 |
Package Statistics | |
---|---|
Total Downloads: | 1,268 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 2 |
Total Forks: | 6 |
Total Open Issues: | 1 |
Image handling solution for Laravel 5, creates thumbs on the fly, handles image cropping, upscaling and resizing.
Works with Laravel 5.1.
Add
"amostajo/laravel-image-handler": "1.0.1"
to your composer.json
. Then run composer install
or composer update
.
Then in your config/app.php
add
Amostajo\LaravelImageHandler\Providers\ImageHandlerProvider::class,
in the providers array.
Then add
'ImageHandler' => Amostajo\LaravelImageHandler\Facades\ImageHandler::class,
in the aliases
array.
Copy and rename the config file [package]\config\config.php
to your laravel's config directory [root]\config\image.php
.
Creating a thumb for an image have never been this easy:
// $imageUrl is exactly that, an image url.
// From either your own website or from an external source.
$url = ImageHandler::thumb($imageUrl);
ImageHandler will actually create a thumb and place it in public/thumbs
directory.
The returned $url
can be placed in a img
html tag like this (sample using blade):
<img src="{{ ImageHandler::thumb($imageUrl) }}"/>
The thumb created will always be cropped to fit the desired size. By default, the thumb will be cropped to the width and height specified in the configuration file, although you can easily set these as parameters:
<img src="{{ ImageHandler::thumb($imageUrl, 800, 180) }}"/>
If you don't want the image to be cropped, prefer to keep constraints and just resize, use these methods instead:
// Resized / scaled to a specific width
$url = ImageHandler::width($imageUrl);
// Resized / scaled to a specific height
$url = ImageHandler::height($imageUrl);
<img src="{{ ImageHandler::width($imageUrl, 350) }}"/>
<img src="{{ ImageHandler::height($imageUrl, 350) }}"/>
Modify the configuration file to adjust the default thumb sizes, set the name of the folder path for the thumbs to be stored and more.
This package is free software distributed under the terms of the MIT license.
This package uses php-image-resize.
Beach Taken from http://beachgrooves.com on 1st of July of 2015.
Sheep Taken from https://guim.co.uk on 1st of July of 2015.