开发者

inline a image that is stored as a string

I have an image that is stored in a string. Instead of taking the time to save it 开发者_开发问答as a file I am trying to display the image inlined.

send_data() does not fit my needs as the method is considered to be a render so the rest of the page will not display.

Is there a better method to do this?


Something along these lines, perhaps?

  #Assuming x holds your image as a string, and is a PNG image
  str = ""
  str << "<script>document.write('<img src=\"data:image/png;base64,"
  str << escape_javascript(Base64.encode64(x))
  str << "\">');</script>"
  raw str
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜