Reputation: 505
I want to show images without using <%= img_tag %>. So I tried following things
<img src="/images/bg/1.jpg" >
<img src="assets/images/bg/1.jpg" >
<img src="assets/bg/1.jpg" >
<img src="bg/1.jpg">
<img src="/bg/1.jpg">
This does not show the image. But if I do this
<%= image_tag("bg/1.jpg") %>
This works. But why it does not work with img tag. How can I make this work?
My image location app/assets/images/bg/1.jpg
Note:
<%= image_tag("bg/1.jpg") %>
outputs
<img src="/assets/bg/1-ed0a6edfcc008f66c22373e3d57a5c01.jpg" >
generated image link is not exactly the original image name
Upvotes: 0
Views: 776
Reputation: 17802
You need to generate link through image_url
if you really want to use the plain img
tag instead of fancy image_tag
by Rails, and here is how:
<img src="<%= image_url('bg/1.jpg') %>">
Upvotes: 1