我想检索src
图像的URL。
{% image "@AcmeMyBundle/Resources/public/image/myimage.jpg" %}
<img src={{ asset_url }}
{% endimage %}
我将如何获得asset_url
控制器内部的信息?
例如 http://example.com/images/c1ca79c_myimage.jpg
甚至images/c1ca79c__myimage.jpg
我尝试过:
$this->container
->get('templating.helper.assets')
->getUrl('@AcmeMyBundle/Resources/public/image/myimage.jpg');
但这将返回字符串,/@AcmeMyBundle/Resources/public/image/myimage.jpg
而不是URL。
其他答案很接近。我真正想要的是:
$this
->get('templating.name_parser')
->parse('@AcmeBundle/Resources/dart/AcmeMain/web/main.dart')
->getPath()
就像我在问题中问的那样,我想使用@
注释。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句