I'm using Active Storage and displaying images in the view like so:
image_tag current_user.user_primary_image.variant(resize_to_limit: [100, 100])
But when I try to resize this particular .png
file:
ActiveStorage::InvariableError
I can stop the error by using .variable?
to display/resize the image conditionally. But there's two problems, i) the image won't display (I want it to), and ii) I don't know why it's happening, so I can't predict when it will happen to other images - afaik, that .png
should be .variable?
true.
So, just to stop errors, I have
<% if current_user.user_primary_image.variable? %>
<%= image_tag current_user.user_primary_image.variant(resize_to_limit: [100, 100]) if current_user.user_primary_image.attached? %>
<% end %>
Since png is one of these file types that should be able to be rezied/displayed, why doesn't the .png
above resize/display, and how can I get it it to work?