Reputation: 23
With simple PHP we can insert an image generated by a PHP script, like :
<img src="image_script.php">
How can we do this with Symfony and Twig ?
Upvotes: 0
Views: 1615
Reputation: 369
I think you should have a look at LiipImagineBundle :
https://github.com/liip/LiipImagineBundle
This bundle allows you to create a cache of resized images.
Upvotes: 0
Reputation: 34107
You can do it in Symfony2 and twig almost like in plain php:
<img src="{{ path("img_action") }}" alt="" />
where img_action
is the route name for the action that returns an image.
In that action, create a new Response
instance, set its contents to the image, set the content-type header to the appropriate MIME type, then return
it.
Upvotes: 2