如何在Paperclip中使用原始图像URL

8

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'}
                  }

在我的公共文件夹中上传一张图片时,我需要创建三个文件夹:缩略图、个人画廊和原始文件。在我的视图文件中,我使用以下代码进行调用:
<%= photo.thumbnail_url %>

我的问题是我想使用上传图像的原始路径。我不想为任何特定的URL使用缩略图。如何使用原始路径。
提前致谢
1个回答

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

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

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接