在没有HTML的Rails中获取图像URL [英] Getting the image URL without the HTML in Rails

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

问题描述

在Rails中,有一种方法可以获取图像的URL(通过assets_host)并仅返回图像的URL?我想在Javascript中使用assets_host数据,但只需要在JS中插入URL,而不是整个image_tag.

In Rails is there a way to get the URL to the image (going through the assets_host) and just return the URL of the image? I want to use assets_host data in my Javascript, but I just need to insert the URL into the JS, not the whole image_tag.

提前谢谢!

推荐答案

image_path 将返回(您猜对了)图像的路径.与image_tag中使用的方法相同.

image_path will return (you guessed it) the path to the image. It's the same method used in image_tag.

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

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