-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add an option to transform AS variants in the background #47473
Conversation
The variants are being loaded on demand, however they will be pushed to the job queue and processed in due course. In active record terms, when the records are eager loaded they are batched together with the original record(s). This naming is a bit too close to AR. |
How about |
@hahmed is there anything I need to do to get this merged? Is renaming |
@shouichi Would need someone from core/committer to review + merge, maybe try discord? |
Thank you! I'll share this PR in discord. |
The feature makes sense to me, but I agree that the naming is weird. Maybe That said, CI is failing for legitimate reasons. |
So personally I prefer Side note: ActiveStorage document uses the term "transform" and "process". I'm not sure which term to stick with. |
4505d6e
to
8611315
Compare
8611315
to
9efdbd5
Compare
@hahmed @casperisfine I changed the option name to |
I still think the naming is a bit weird. I do understand the reasoning of using Hence why I think something in the lines of |
The term How about |
Not bad. Perhaps |
cc @byroot |
9efdbd5
to
4b81552
Compare
ActiveStorage variants are processed on the fly when they are needed but sometimes we're sure that they are accessed and want to processed them upfront. `preprocessed` option is added when declaring variants. ``` class User < ApplicationRecord has_one_attached :avatar do |attachable| attachable.variant :thumb, resize_to_limit: [100, 100], preprocessed: true end end ```
4b81552
to
b1c544b
Compare
I decided to use |
I'm really excited to use this feature; Any idea when it will get merged into stable? I had hoped to see it in 7.0.8 |
New features get released with the next major version, so it will be available in 7.1 (7.0 is bugfix only) |
@shouichi I am looking to extend this with an option to transform immediately, |
Though the apps I manage don't need the feature, I can imagine some apps need one. For example, in a chat-like app, when someone posts an image, many users access the image thumbnail simultaneously. In that case, it makes sense to create a thumbnail before broadcasting. |
Motivation / Background
ActiveStorage variants are transformed on the fly when they are needed
but sometimes we're sure that they are accessed and want to transform
them upfront.
Detail
preprocessed
option is added when declaring variants.Additional information
See also #47387.
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]