Is there a way to determine the existence of a given image style?
For example to determine whether the image exists at all, we can do:
<% if @user.avatar.exists? %>
<%= image_tag @user.avatar.url(:large), :id => "cropbox" %>
But how can we determine whether the image exists in a particular style, say for instance thumb
?. The above condition only determines the existence of an image in its original
style.
The .exists?
function optionally takes a style_name:
<% if @user.avatar.exists?(:large) %>
should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With