Path for images in <img> tags
While embedding images with html there is an issue with mentioning image path . A path starting with "http://localhost:3000/" sends the rails server into a loop .
question = IMGKit.new('< img_tag src = 'http://localhost:3000/assets/qimage/629a3a4_1_original.jpg' />',:quality => 100)
question.to_file("/home/superq/quizot/app/assets/images/questions/test_123.jpg")
If I use an absolute path of my local machine , it works fine . However that is not a very convenient option . How should the path of the image be mentioned ? I am on Rails 3
Note : I am using img_tag above so that it is not picked up as an actual tag here.
I'm having the same issue too.
Did you manage to find a workaround for this yet ? I am still stuck .
I'm working with absolut path too. It's not the best way, but i needed to complete the project.
What about using File.expand_path to get the abslolute path?
The Gem doesn't really know whereabouts you'd like to store the file (should It be relative to RAILS_ROOT, __FILE__), etc.
Anyways, those are just my first thoughts -- leave it as an exercise for the reader. :)
Workaround
<% background = File.read("#{Rails.root}/app/assets/images/backgound.png") %>
<img src="<%= 'data:image/png;base64,' + Base64.strict_encode64(background) %>" />