Created
November 1, 2012 19:11
-
-
Save ChubV/3995779 to your computer and use it in GitHub Desktop.
Cropped thumbnail filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
avalanche_imagine: | |
filters: | |
gallery_cropped: | |
type: crop_thumb | |
options: { size: [200, 200] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ChubProduction\Bundle\SiteBundle\Imagine; | |
use Imagine\Image\Box; | |
use Imagine\Image\Point; | |
use Imagine\Filter\Transformation; | |
use Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; | |
use Imagine\Image\ManipulatorInterface; | |
/** | |
* CroppedThumbFilter | |
* | |
* @author Vladimir Chub <[email protected]> | |
*/ | |
class CroppedThumbFilterLoader implements LoaderInterface | |
{ | |
public function load(array $options = array()) | |
{ | |
list($width, $height) = $options['size']; | |
$transformation = new Transformation(); | |
$box = new Box($width, $height); | |
$transformation->thumbnail($box, ManipulatorInterface::THUMBNAIL_OUTBOUND) | |
->crop(new Point(0, 0), $box); | |
return $transformation; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="{{ asset(photo.url)|apply_filter('gallery_cropped') }}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
class: ChubProduction\Bundle\SiteBundle\Imagine\CroppedThumbFilterLoader | |
tags: | |
- { name: imagine.filter.loader, filter: crop_thumb} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment