crowdreactive / cloud-resizer-bundle
A bundle for resizing and manipulating images using web services
dev-master
2014-09-04 15:38 UTC
Requires
- symfony/config: ~2.2
- symfony/dependency-injection: ~2.2
- symfony/http-kernel: ~2.2
- twig/twig: *
Requires (Dev)
- fabpot/php-cs-fixer: dev-master
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-12-17 02:04:30 UTC
README
Provides a wrapper around external image manipulation services. Currently supporting:
Usage
Standalone
use CrowdReactive\CloudResizerBundle; $resizer = new CloudResizerBundle\Services\CloudResizer; // Setup providers $cloudImage = new CloudResizerBundle\Provider\CloudImage(CLOUDIMAGE_TOKEN); // Create filters for different purposes $backgroundThumbnail = new CloudResizerBundle\CloudResizer\CloudImage\CloudImageFilter($cloudImage, ['height' => 200]); $resizer->setFilter('background_thumb', $backgroundThumbnail); $resizer->build('https://s3.amazonaws.com/.../uploads/background-123.png', 'background_thumb'); $resizer->build('https://s3.amazonaws.com/.../uploads/background-123.png', 'background_thumb', ['height' => 400]);
Symfony integration
CloudResizer can be used as a Symfony bundle:
// app/AppKernel.php public function registerBundles() { return [ // ... new CrowdReactive\CloudResizerBundle\CrowdReactiveCloudResizerBundle(), ]; }
# app/config/config.yml services: cloudresizer.provider.cloudimage: class: CrowdReactive\CloudResizerBundle\Provider\CloudImage args: [%cloudimage_token%] crowdreactive_cloudresizerbundle: filters: background_thumb: provider: @cloudresizer.provider.cloudimage parameters: height: 50
Twig usage
<img src="{{ page.style.background_image.url|cloudresizer('background_thumb') }}"> <img src="{{ page.style.background_image.url|cloudresizer('background_thumb', {'height': 50}) }}">