-
Notifications
You must be signed in to change notification settings - Fork 21.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ActiveStorage] Add ability to use pre-defined variants #39135
Conversation
Let's yield an actual object (yes, no class User < ActiveRecord::Base
has_one_attached :avatar do |blob|
blob.variant :thumb, resize: "100x100"
blob.variant :medium, resize: "300x300", monochrome: true
end
end
class Gallery < ActiveRecord::Base
has_many_attached :photos do |blob|
blob.variant :thumb, resize: "100x100"
blob.variant :medium, resize: "300x300", monochrome: true
end
end Note: there's a potential reading of this API version that makes it look like we're eagerly computing the variants, so whatever ideas you'd have to clarify that are welcome. (Perhaps renaming the yielded variable to |
2b4a231
to
a1d2460
Compare
@kaspth Updated using the block syntax. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
I’d be interested in such a feature. |
@georgeclaghorn @kaspth |
I definitely need this feature, would be great if this can be a part of the next release. |
Hey guys, That would be awesome to see this feature merged! How could we help @fatkodima @rafaelfranca? 🙏 |
@fatkodima nice job! Sorry for the delay on my end 🙏 |
@fatkodima Thanks for your contribution. I referred to this PR and created a gem supporting Rails 6 projects to have this nice feature. |
Am i missing something? Im getting |
@SylarRuby PR description is outdated. Look at the code changes and changelog. |
I'm also experiencing this error. |
@jmarsh24 like above, look at the PR code and the changelog to see how to use variants. I wonder if there's any hope of using these with attachment previews too. |
Related discussion