microstudi / silex-image-controller
Microstudi/Image Controller Service Provider for Silex.
Installs: 2 021
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 1
Requires
- php: >=5.5.9
- microstudi/silex-intervention-image: ~2.0
Requires (Dev)
- phpunit/phpunit: ~4.7
- silex/silex: ~2.0
This package is not auto-updated.
Last update: 2024-12-20 17:02:13 UTC
README
A auto-image resize controller using Intervention/image service provider for Silex
Requirements
- PHP >= 5.5.9 (Same as Silex 2.0)
InterventionImageServiceProvider
Install
Using composer:
composer require microstudi/silex-image-controller
Usage
use Microstudi\Silex\ImageController\ImageController; use Microstudi\Silex\InterventionImage\InterventionImageServiceProvider; $app = new Silex\Application(); $app->register(new InterventionImageServiceProvider); ; //Automatic images $app->mount('/your_path', new ImageController(array( 'image_path' => '/path/to/original/images', 'image_cache_path' => '/path/to/cache/folder' ) )); $app->run();
Twig Helper: If twig is present a convenient function can be used to generate proper urls for auto-resized images image_path(image, size)
:
{{ image_path('path/to/image.png', 100, 100) }} {{ image_path('path/to/image.png', 100, 100, 'c') }}
URLs examples:
your_path/200x300/products/image_product.jpg <- width or height will be
changed if necessary but
never increased
your_path/200x300xc/products/image_product.jpg <- cropped, ensures exact sizes
your_path/200x0/products/image_product.jpg <- auto-calculate height
your_path/0x300/products/image_product.jpg <- auto-calculate width
Options
intervention.image
- Instance ofIntervention\Image\ImageManager
.intervention.response
- For use ImageManager directly such as$app['intervention.response']($image)
intervention.driver
- Driver used (imagick or gd)
Tests
$ composer install $ vendor/bin/phpunit
Changelog
2.0.2
- README example fix.
2.0.0
- Updated for Silex 2.0
1.0.1
- Readme fix
- Locked Silex to version 1.1
1.0.0
- First release
LICENSE
The MIT LICENSE (MIT)