Afunakwa
Afunakwa

Reputation: 437

Produce dynamic thumbnail on-the-fly in twig with liipimaginebundle

I'm trying to use liipImagineBundle in symfony to produce thumbnails on the fly. The url of the image to be used as a thumbnail being attached to an Entry entity, my twig file calls the image like so:

 <img src="{{ asset('uploads/images/') ~ entry.thumbnail | imagine_filter('my_thumb') }}" />

and it doesn't seem to work. I've tried tweaking the data_root attribute of liipimagine's config but without success. I can't seem to tell liip that my image is in web/uploads/images. The source html ends up looking like this:

 <img src="/projects/ootn_symf/web/uploads/images/http://localhost/projects/ootn_symf/web/app_dev.php/media/cache/resolve/my_thumb/my_image.jpg" />

Currently, liip's config is the following:

liip_imagine:
    resolvers:
       default:
          web_path: ~

    filter_sets:
        cache: ~
        my_thumb:
            quality: 75
            filters:
                thumbnail: { size: [120, 90], mode: outbound }

Not sure what to do here, can someone help me?

Upvotes: 1

Views: 1662

Answers (1)

pabgaran
pabgaran

Reputation: 773

That result is beacuse the filter only applies to "entry.image"

Try this:

<img src="{{ asset('uploads/images/' ~ entry.thumbnail)  | imagine_filter('my_thumb') }}" />

Or:

 <img src="{{ (asset('uploads/images/') ~ entry.thumbnail) | imagine_filter('my_thumb') }}" />

I hope it helps.

Upvotes: 1

Related Questions