加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何在回形针中使用原始图像URL

发布时间:2020-12-17 04:39:12 所属栏目:百科 来源:网络整理
导读:由paperclip上传的图像的原始路径是什么. has_attached_file :attachment,:url = ":rails_root/public/photos/images/:id/:style/:basename.:extension",:default = ":rails_root/public/images/no-image-available.png",:styles = style_options,:default_s
由paperclip上传的图像的原始路径是什么.
has_attached_file :attachment,:url  =>           ":rails_root/public/photos/images/:id/:style/:basename.:extension",:default =>        ":rails_root/public/images/no-image-available.png",:styles =>          style_options,:default_style =>   :gallery

和style_options是

style_options = {  :thumbnail => {:geometry => '100x100'},:profile_gallery =>  {:geometry => '184x247'}
                  }

在我的公共文件夹中创建3个文件夹,同时一个图像上传1.缩略图,2.profile_gallary 3.原始.

在我的视图文件中,我打电话

<%= photo.thumbnail_url %>

我的问题是我想使用上传图片的原始路径.我不想将thumnail用于任何特定网址.我怎样才能使用原始路径.

感谢Advance

解决方法

<%= photo.attachment.url(:original) %>

这将为您提供原始文件的路径,如果需要,您还可以获取其他样式:

<%= photo.attachment.url(:thumbnail) %>
<%= photo.attachment.url(:profile_gallery) %>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读