如何在Rails中显示URL指向的图像 [英] How to display image pointed by URL in Rails

查看:149
本文介绍了如何在Rails中显示URL指向的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我这里有一张图片 http://power.itp.ac.cn/~jmyang/funny/fun4.jpg 我希望在我的Rails网站上显示它。我该怎么做?

I have a image here http://power.itp.ac.cn/~jmyang/funny/fun4.jpg and I want to display it in my Rails site. How should i do that?

编辑:嗯,伙计们,我现在明白了这些投票。这是因为它太天真了一个问题:)对不起,在问这个问题之前我几乎不了解HTML标签,但感谢Rails,即使我自己也可以建立一个网站。 Rails rock!

Well, guys , I understand the downvotes now. It is because it is too naive a question:) Sorry, I knew almost nothing about HTML tags before asking the question, but thanks to Rails, even I could build a web site myself. Rails rocks!

推荐答案

您还可以使用操作视图 image_tag helper :

You can also use the action view image_tag helper:

<%= image_tag 'http://power.itp.ac.cn/~jmyang/funny/fun4.jpg' %>

或者你可以使用常规的HTML标签:

Alternatively you can just use the regular HTML tags:

ERB:

<img src="http://power.itp.ac.cn/~jmyang/funny/fun4.jpg">

Haml:

%img{ src: "http://power.itp.ac.cn/~jmyang/funny/fun4.jpg" }

超薄:

img src="http://power.itp.ac.cn/~jmyang/funny/fun4.jpg"

这篇关于如何在Rails中显示URL指向的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆