开发者

Symfony: image not showing in Layout.php

开发者 https://www.devze.com 2023-03-14 08:45 出处:网络
<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 goi
<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

精彩评论

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