Symfony2图像在树枝模板中的路径

kon*_*ian 22 symfony twig assetic

我存储img,Acme/DemoBundle/Resources/public/img/weather_icon/blizzard.gif 我想把这个img放在我的模板中,所以我做了

<img src="{{ asset('bundles/acmedemo/img/weather_icons/blizzard.gif') }}" />
Run Code Online (Sandbox Code Playgroud)

<img src="{{ asset('..img/weather_icons/blizzard.gif') }}"  />
Run Code Online (Sandbox Code Playgroud)

这不起作用.我做了资产:安装和资产:转储

解决了它的工作原理

<img src="{{ asset('img/weather_icons/Blizzard.gif') }}" alt="Symfony!" />
Run Code Online (Sandbox Code Playgroud)

Nis*_*sam 34

请试试这个

<img src="{{ asset('bundles/acmedemo/img/weather_icons/blizzard.gif') }}" />
Run Code Online (Sandbox Code Playgroud)

您应该使用该命令将资产存入Web目录

app/console assets:install web
Run Code Online (Sandbox Code Playgroud)


Chr*_*eel 5

您可以使用捆绑的图像:

{% image '@CoreBundle/Resources/public/images/your-image.jpg'  output="images/your-image.jpg" %}
<img src="{{ asset_url }}" width="100%" height="100%" alt="my alt of image" class="pull-left">
{% endimage %}
Run Code Online (Sandbox Code Playgroud)