[英]Why won't image_tag show an image on site
I'm working in Cloud 9, trying to display an image using the image_tag
and I'm getting this placeholder symbol that Chrome can't find my image. 我正在Cloud 9中工作,试图使用image_tag
显示图像,但我收到一个占位符,表示Chrome无法找到我的图像。 I uploaded the image from my computer to assets/images/logos/light_blue.png
. 我将图像从计算机上载到assets/images/logos/light_blue.png
。
I don't understand why the image doesn't show up. 我不明白为什么图片不显示。 The code I use is: 我使用的代码是:
<%= image_tag ("light_blue.png") %>
A screenshot of the code 代码的屏幕截图
The result in the browser 浏览器中的结果
The same thing happens with a JPG. JPG也会发生相同的情况。
Rails is searching for your image in the directory ./assets
and not in ./assets/images/logos/light_blue.png
. Rails在目录./assets
搜索图像,而不是在./assets/images/logos/light_blue.png
搜索图像。
If you change the path, it will work, if the image is in that folder. 如果您更改了路径,并且该图像位于该文件夹中,那么它将起作用。
<%= image_tag ('images/logos/light_blue.png') %>
The documentation gives you a few more examples. 该文档为您提供了更多示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.