Ahmed Gaber
Ahmed Gaber

Reputation: 708

Symfony2: LiipImagineBundle - Exception: Unable to generate a URL for the named route "_imagine_image_upload_thumbnail" as such route does not exist

I am using LiipImagineBundle

I have followed installing instruction as in the documentation

in AppKernel.php

new Liip\ImagineBundle\LiipImagineBundle(),

and in routing.yml

# app/config/routing.yml

_imagine:
    resource: .
    type:     imagine

And in config.yml

#app/config/config.yml
liip_imagine:
    filter_sets:
        image_upload_thumbnail:
            quality: 85
            filters:
                thumbnail: { size: [150, 150], mode: outbound }

and in my twig file

<img alt="{{ media.title|default('untitled') }}" src="{{ media.getWebPath | imagine_filter('image_upload_thumbnail') }}"/>

I get this error

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_imagine_image_upload_thumbnail" as such route does not exist.") 

What i have tried :

Upvotes: 1

Views: 1700

Answers (1)

Nicolai Fr&#246;hlich
Nicolai Fr&#246;hlich

Reputation: 52493

Try the following:

remove the spaces:

{{ media.webPath|imagine_filter('...') }}

... or invoke as a function:

{{ imagine_filter( media.webPath, 'filtername', false ) }}

Twig seems to invoke imagine_filter as a twig function instead of as a twig filter.

You end up with media.webPath not being passed as an argument.

( tip: just use media.webPath instead of media.getWebPath - twig will automatically call the getter for you )

Actually the underlying function filter() accepts the image-path as the first and the filter-name as it's second argument.

The third argument (boolean) determines wether to generate a relative or absolute url - defaults to false (relative).

Curently imagine uses the filter-name as a route-name and tries to generate a url ... which of course doesn't work :)

Upvotes: 1

Related Questions