微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

由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) %>

原文地址:https://www.jb51.cc/ruby/269675.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐