The idea of named variants (merged pull request) is to be able to define image variants (i.e. different sizes) in 1 place (in the Model
), instead of redundantly and all over your Views
.
But, if you’re in a situation in which you need to…
- Keep the uploaded original image unchanged, and
- Crop the image (based on coordinates supplied by the user), to then:
- Create several variants (based on the cropped version)
… I believe that this would be impossible in the current version of “named variants”, an example of which looks like this:
class User < ApplicationRecord
has_one_attached :avatar do |attachable|
attachable.variant :large, resize_to_limit: [300, nil]
attachable.variant :medium, resize_to_limit: [100, nil]
attachable.variant :small, resize_to_limit: [ 50, nil]
end
end
Or am I missing something?
Would this be an idea for an update to the Rails core?