I want to replace <%= link_to image_tag ("picture.png")
with something like this: <img src="/path/picture.png" />
in a file.html.erb
But when I do this, and it works without any error, but no picture shows up on the page.
The <img> tag creates a holding space for the referenced image. The <img> tag has two required attributes: src - Specifies the path to the image. alt - Specifies an alternate text for the image, if the image for some reason cannot be displayed.
The img element has two required attributes: src : The source location (URL) of the image file. alt : The alternate text. This is used to describe the image for someone who cannot see it because they are either using a screen reader or the image src is missing.
Of course you can put an IMG tag inside an A tag. There's nothing wrong with it.
Img src Not Working That means, when a web page loads, the browser has to retrieve the image from a web server and display it on the page. The broken link icon means that the browser could not find the image. If you've just added the image, then check that you included the correct image URL in the source attribute.
You could do:
<img src="<%= image_path('picture.png') %>" />
But I don't see why this is better than:
<%= image_tag("picture.png") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With