Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic filter with liipImagineBundle
    primarykey
    data
    text
    <p>I'm using liipImagineBundle and am trying to apply a filter directly into a controller.</p> <p>In the doc I found two sections in which explains how to use liipImagineBundle from the controller. This one <a href="https://github.com/liip/LiipImagineBundle#using-the-controller-as-a-service" rel="nofollow noreferrer">https://github.com/liip/LiipImagineBundle#using-the-controller-as-a-service</a></p> <pre><code>public function indexAction() { // RedirectResponse object $imagemanagerResponse = $this-&gt;container -&gt;get('liip_imagine.controller') -&gt;filterAction( $this-&gt;getRequest(), 'uploads/foo.jpg', // original image you want to apply a filter to 'my_thumb' // filter defined in config.yml ); // string to put directly in the "src" of the tag &lt;img&gt; $srcPath = $imagemanagerResponse-&gt;headers-&gt;get('location'); // .. } </code></pre> <p>And <a href="https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/filters.md#dynamic-filters" rel="nofollow noreferrer">https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/filters.md#dynamic-filters</a></p> <pre><code>public function filterAction(Request $request, $path, $filter) { $targetPath = $this-&gt;cacheManager-&gt;resolve($request, $path, $filter); if ($targetPath instanceof Response) { return $targetPath; } $image = $this-&gt;dataManager-&gt;find($filter, $path); $filterConfig = $this-&gt;filterManager-&gt;getFilterConfiguration(); $config = $filterConfig-&gt;get($filter); $config['filters']['thumbnail']['size'] = array(300, 100); $filterConfig-&gt;set($filter, $config); $response = $this-&gt;filterManager-&gt;get($request, $filter, $image, $path); if ($targetPath) { $response = $this-&gt;cacheManager-&gt;store($response, $targetPath, $filter); } return $response; } </code></pre> <p>I tested as indicated in "Using the controller as a service" and it works, the problem I have is that I don't know how to access the filter settings to modify it.</p> <pre><code>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 } </code></pre> <p>The second, really, I don't understand when he says "With a custom data loader...". </p> <p>In the example he is only modifying the method filteraction() from the ImagineController class (Liip\ImagineBundle\Controller). I wonder how I can modify that method dynamically? For example from my controller indexAction().</p> <p>Also i have read this post <a href="https://stackoverflow.com/questions/16166719/loading-your-custom-filters-with-liipimaginebundle">https://stackoverflow.com/questions/16166719/loading-your-custom-filters-with-liipimaginebundle</a> where @NSCoder says that "You can use the built in filter and modify their configuration." but i don't understand it.</p> <p>I've been looking for several days but I haven't found an example from which to start.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload