My *_*God 10 upload ruby-on-rails image paperclip
有没有办法确定给定图像样式的存在?
例如,要确定图像是否存在,我们可以:
<% if @user.avatar.exists? %>
<%= image_tag @user.avatar.url(:large), :id => "cropbox" %>
Run Code Online (Sandbox Code Playgroud)
但是,我们如何确定图像是否以特定的样式存在,比如说thumb?上述条件仅确定其original样式中图像的存在.
Ale*_*tie 29
该.exists?函数可选地采用style_name:
<% if @user.avatar.exists?(:large) %>
Run Code Online (Sandbox Code Playgroud)
应该管用.
Ric*_*wis -2
尝试这样的事情
<% if @user.avatar(params[:large]) %><%= image_tag @user.avatar.url(:large), :id => "cropbox" %><% end %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2093 次 |
| 最近记录: |