anahkiasen / illuminage
Wrapper for the Imagine library to hook into the Laravel framework
Installs: 4 249
Dependents: 1
Suggesters: 0
Security: 0
Stars: 18
Watchers: 5
Forks: 4
Open Issues: 1
Requires
- php: >=5.3.0
- anahkiasen/html-object: ~1.4.0
- illuminate/cache: ~4.1
- illuminate/config: ~4.1
- illuminate/container: ~4.1
- illuminate/routing: ~4.1
- illuminate/support: ~4.1
- imagine/imagine: ~0.5.0
Requires (Dev)
- mockery/mockery: ~0.9.0
This package is auto-updated.
Last update: 2024-11-08 00:36:55 UTC
README
Illuminage
Setup
First do composer require anahkiasen/illuminage:dev-master
.
Then if you're on a Laravel app, add the following to the providers
array in app/config/app.php
:
'Illuminage\IlluminageServiceProvider',
And this in the facades
array in the same file :
'Illuminage' => 'Illuminage\Facades\Illuminage',
And then do artisan asset:publish anahkiasen/illuminage
.
Usage
Illuminage is a wrapper for the Imagine library to hook into the Laravel framework. It implements elegant shortcuts around Imagine and a smart cache system.
// This will create a cropped 200x300 thumb, cache it, and display it in an image tag echo Illuminage::thumb('image.jpg', 200, 300) // or echo Illuminage::image('image.jpg')->thumbnail(200, 300) // Shortcuts echo Illuminage::square('image.jpg', 300)
What you get from those calls are not direct HTML strings but objects implementing the HtmlObject\Tag abstract, so you can use all sorts of HTML manipulation methods on them :
$thumb = Illuminage::square('image.jpg', 200)->addClass('image-wide'); $thumb = $thumb->wrapWith('figure')->id('avatar'); echo $thumb; // <figure id="avatar"><img class="image-wide" src="pathToThumbnail.jpg"></figure>
You can at all time access the original Imagine instance used to render the images :
$thumb = Illuminage::image('foo.jpg')->thumbnail(200, 200); echo $thumb->grayscale()->onImage(function($image) { $image->flipVertically()->rotate(45); });