I'd like to retrieve the src
URL of an image.
{% image "@AcmeMyBundle/Resources/public/image/myimage.jpg" %}
<img src={{ asset_url }}
{% endimage %}
How would I get the asset_url
inside the controller?
e.g. http://example.com/images/c1ca79c_myimage.jpg
or even images/c1ca79c__myimage.jpg
I tried:
$this->container
->get('templating.helper.assets')
->getUrl('@AcmeMyBundle/Resources/public/image/myimage.jpg');
But this returns the string /@AcmeMyBundle/Resources/public/image/myimage.jpg
and not a URL.
The other answers were close. What I really wanted was:
$this
->get('templating.name_parser')
->parse('@AcmeBundle/Resources/dart/AcmeMain/web/main.dart')
->getPath()
Like I asked in my question I wanted to use the @
annotation.