feat(Picture): Add support for only and except setting#3522
Draft
feat(Picture): Add support for only and except setting#3522
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3522 +/- ##
==========================================
- Coverage 97.46% 97.45% -0.02%
==========================================
Files 314 314
Lines 8218 8239 +21
==========================================
+ Hits 8010 8029 +19
- Misses 208 210 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b318d92 to
cd69a59
Compare
2e0aed3 to
328668c
Compare
Use Ruby's `File.basename` and Rails' `humanize` to create the first initial human readable `name` of `Attachment`s and `Picture`s. Before we where using our own brittle Regexp, that expected the file suffix to be known from it's mime type. This is not the case for unknown mimetypes. We also move the name conversion before filename sanitization in order to get a nice human readable name and not escape characters. Since the name is not used to load the file and all output is escaped in Rails by default, this is fine. Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Both Attachment.file_types and Picture.file_formats now delegate from_extensions handling to the storage adapter's file_formats method. Each adapter converts extensions to the format it uses internally: Dragonfly keeps bare extensions for pictures and converts to MIME types for attachments, while Active Storage always converts to MIME types via Marcel. This removes the Marcel conversion that lived in Attachment.file_types and centralizes all format-aware logic in the adapters where it belongs.
The Picture ingredient now supports `only` and `except` settings to constrain which image formats are available in the picture library overlay, matching the existing Attachment/File ingredient behavior. Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
We never used the not_file_type scope, but used the by_file_type scope with a inverted collection instead. Also use Attachment.file_types(from_extensions:) instead of inline Marcel::MimeType.for conversion.
328668c to
1712cc0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this pull request for?
This allows to use
onlyandexceptsetting onPictureingredients like onFileingredients.TODO
Checklist