【问题标题】:How to get only image src attribute from rails image_tag?如何从 rails image_tag 仅获取图像 src 属性?
【发布时间】:2021-12-21 09:07:28
【问题描述】:

我有一个场景,我只需要image_tag生成的src属性。

ActionController::Base.helpers.image_tag("diane.png")

回馈

<img src=\"/assets/diane-d88012c06a724682b02dfbd9224dbaac15872a3.png\" alt=\"Diane\" />

我只需要src 属性中的字符串。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-5


    【解决方案1】:

    你可以使用image_path:

     ActionController::Base.helpers.image_path("diane.png") 
    

    【讨论】:

    • 正是我想要的。谢谢
    猜你喜欢
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多