开发者

Symfony: image not showing in Layout.php

<img src="/images/example.png" alt="example" />

Shows up when written in the template (i.e. indexS开发者_JAVA百科uccess.php), but only displays the alt when used in layout.php. What is going on here?

Thanks.


It was an image path problem. The problem was that layout was being applied to different urls: e.g. example.com/ / example.com/admin.php, so the relative path of image/example.png did not work for all the cases. Maerlyn mentioned in the comments the use of image_path() helper function. With that the problem was solved.

TL;DR: Use image_path() in the layout (doesn't hurt to use in templates as well, i suppose)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜