-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Use Active Storage for Picture and File attachments #2968
base: main
Are you sure you want to change the base?
Conversation
0b43fa0
to
2b7123c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2968 +/- ##
==========================================
- Coverage 96.58% 96.40% -0.19%
==========================================
Files 236 225 -11
Lines 6334 6261 -73
==========================================
- Hits 6118 6036 -82
- Misses 216 225 +9 ☔ View full report in Codecov by Sentry. |
b4a85f8
to
9bedb48
Compare
It would be great to support uploads on the Resources, to use it when Alchemy is being used as admin for other models. |
This change is not related to allow attachments in Rails models. You can already do this with established Rails ways. There is nothing special about that in Alchemy. The model is yours. Just use it as normal Rails model. |
59d4563
to
77a78ef
Compare
b4a03f9
to
9587e59
Compare
9b2e8f7
to
fd3afe9
Compare
Necessary for active storage image transforms
ActiveStorage uses the image_processing gem to process images. This uses a hash to describe the conversion instead of a string
Instead of using the Dragonfly Model validations we write our own. That way we can use another image attachment library more easily
The vips image_processing processor sharpens images by default. This disables this behavior.
Active storage already knows if a file is convertible
This avoids N+1 in the image library
Using activestorage methods to read the values. Ideally we would cache these values, but active storage asynchronously sets these values and provides no callback we could use.
Now that we use ActiveStorage we can remove our custom picture variant handling
This method is the only one left after the PictureVariant and PictureThumb removal.
Active storage has the mime type stored not the extension.
ruby-vips and mini_magick need to be told to ignore the page in order to resize animated gifs.
Before we where not telling active storage that we want a certain format explicitely. We need that for displaying animated PNGs properly.
Proxy downloads the file.
Only works in Rails 7.1
ActiveStorage expects an extension and not an mime type.
It is only configured by default in unreleased Rails 7.2
fd3afe9
to
38b4972
Compare
What is this pull request for?
Use ActiveStorage instead of Dragonfly for picture and file attachments.
Important changes
vips
. It works withmini_magick
thoughTODO
Alchemy::Attachment
as wellmini_magick
(?? still a thing ??)Checklist