-
-
Notifications
You must be signed in to change notification settings - Fork 314
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.63% 96.44% -0.19%
==========================================
Files 235 224 -11
Lines 6324 6242 -82
==========================================
- Hits 6111 6020 -91
- Misses 213 222 +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. |
lib/alchemy_cms.rb
Outdated
@@ -9,6 +9,8 @@ | |||
require "active_model_serializers" | |||
require "awesome_nested_set" | |||
require "cancan" | |||
require "dragonfly" | |||
require "dragonfly_svg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to upgrader
lib/tasks/alchemy/upgrade.rake
Outdated
Alchemy::Upgrader.display_todos | ||
end | ||
|
||
namespace "7.3" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to 8.0
59d4563
to
77a78ef
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
0b5bd57
to
b4a03f9
Compare
b4a03f9
to
9587e59
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
Checklist