Reputation: 63
How can I call an image of some url external website using image_tag in a rails html view? Please, I'm looking for an alternative using image_tag not the regular html or css
Upvotes: 2
Views: 4477
Reputation: 113
Say you have an SVG file that is the image and it points to your Github or Linkedin profile, you could do something like this:
Setup:
Procedure
<%= link_to image_tag("linkedin.svg"), "http://www.linkedin.com/in/myprofile", :target => "_blank"%>
"http://www....."
Upvotes: 0
Reputation: 786
EDIT Turns out OP wanted to do this b/c Heroku wasn't pulling in images from the assets folder. It is an issue that is easily resolved by reading/following the instructions here: Rails 4 images not loading on heroku .
Leaving the original answer here as it more correctly answers the original question.
image_tag
works with full urls. So you could just give it the URL to the site you want to pull from. i.e:
<%= image_tag 'https://placekitten.com/800/400' %>
I'm sure you are already aware of this, but in 99.999% of situations, hot-linking images from other sites is a very bad idea.
Upvotes: 1