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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/ruby/269675.html

猜你在找的Ruby相关文章