Symfony2 树枝模板中图像的路径 [英] Symfony2 Path to image in twig template

查看:30
本文介绍了Symfony2 树枝模板中图像的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I store img in Acme/DemoBundle/Resources/public/img/weather_icon/blizzard.gif I want to put this img in my template so I did

<img src="{{ asset('bundles/acmedemo/img/weather_icons/blizzard.gif') }}" />

<img src="{{ asset('..img/weather_icons/blizzard.gif') }}"  />

这没有用.我做了资产:安装和资产:转储

And this did't work. I did assets:install and assetic:dump

已解决成功了

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

推荐答案

请试试这个

<img src="{{ asset('bundles/acmedemo/img/weather_icons/blizzard.gif') }}" />

您应该使用命令将资产安装到 web 目录中

You should istall your assets into web directory with the command

app/console assets:install web

这篇关于Symfony2 树枝模板中图像的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆