1
votes

I am using ImagineBundle and I'm trying to display a filtered image.

My twig code is this:

<img src="{{ currentProfileImage|default|imagine_filter('my_thumb') }}" />

Without the filter, the image is displayed correctly from the path:

<img src="/bundles/templates/uploads/images/my_folder/01c2b593148119e2dbcf40fef147542b.jpeg" />

But with the filter applyed, I get the following output:

<img src="http://www.example.com/media/cache/my_thumb/bundles/templates/uploads/images/my-folder/01c2b593148119e2dbcf40fef147542b.jpeg" />

With the filter applied, the image is not displayed.. if I try to copy / paste in address bar the path: http://www.example.com/media/cache/my_thumb/bundles/templates/uploads/images/my-folder/01c2b593148119e2dbcf40fef147542b.jpeg

is says Route not Found..

I realised that any image that is not placed in web/bundles folder is not displayed..

Any ideas?

Thanks

UPDATE: config.yml looks like this:

liip_imagine:
resolvers:
   default:
      web_path: ~

filter_sets:
    cache: ~
    my_thumb:
        quality: 75
        filters:
            thumbnail: { size: [120, 90], mode: outbound }
1
Have you tried the URL http://www.example.com/bundles/templates/uploads/images/my_folder/01c2b593148119e2dbcf40fef147542b.jpeg? - Alvin Bunk
There is the original image, not resized, and it works. I want to display the resized image which is in we/cache/media... folder. - TeoM

1 Answers

2
votes

It seems that you forgot to add routing as mentioned in LiipImagineBundle's description:

# app/config/routing.yml

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

When using this bundle you're not accessing images directly. You get an url to ImagineBundle's action that checks if file exists in cache folder (which means it's already generated), and if not, it creates one.