控制器中的Symfony2图像路径

单身的

我想检索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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章