I am using liipImagineBundle and trying to apply a filter directly to the controller.
I found two sections in the document that explain how to use the liipImagineBundle from the controller. This https://github.com/liip/LiipImagineBundle#using-the-controller-as-a-service
public function indexAction()
{
$imagemanagerResponse = $this->container
->get('liip_imagine.controller')
->filterAction(
$this->getRequest(),
'uploads/foo.jpg',
'my_thumb'
);
$srcPath = $imagemanagerResponse->headers->get('location');
}
And https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/filters.md#dynamic-filters
public function filterAction(Request $request, $path, $filter)
{
$targetPath = $this->cacheManager->resolve($request, $path, $filter);
if ($targetPath instanceof Response) {
return $targetPath;
}
$image = $this->dataManager->find($filter, $path);
$filterConfig = $this->filterManager->getFilterConfiguration();
$config = $filterConfig->get($filter);
$config['filters']['thumbnail']['size'] = array(300, 100);
$filterConfig->set($filter, $config);
$response = $this->filterManager->get($request, $filter, $image, $path);
if ($targetPath) {
$response = $this->cacheManager->store($response, $targetPath, $filter);
}
return $response;
}
I tested as indicated in "Using the controller as a service" and it works, the problem is that I do not know how to access the filter settings in order to change it.
liip_imagine:
driver: gd
web_root: %kernel.root_dir%/../web
data_root: %kernel.root_dir%/../web
cache_mkdir_mode: 0777
cache_prefix: /media/cache
cache: web_path
cache_clearer: true
data_loader: filesystem
controller_action: liip_imagine.controller:filterAction
formats: []
filter_sets:
my_thumb:
filters:
crop: { start: [0, 0], size: [200, 150] }
my_paste:
quality: 90
filters:
paste: { start: [30, 60], image: ../web/uploads/images/firma.jpg }
The second one, really, I don’t understand when he says: "Using a special data loader ...".
filteraction() ImagineController (Liip\ImagineBundle\Controller). , ? , indexAction().
https://stackoverflow.com/questions/16166719/loading-your-custom-filters-with-liipimaginebundle, @NSCoder , " ". .
, , .