Skip to content
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

Update image? check for file upload field types #3398

Merged
merged 3 commits into from Oct 2, 2021

Conversation

codealchemy
Copy link
Contributor

Lookup the type via the extension, and match against 'image' types.

Rails provides a way to register custom mime types, allowing additional 'image' types to be added to an Rails application without needing to maintain a list of specific filename extensions in rails_admin

ex. webp

# config/initializers/mime_types.rb
Mime::Type.register 'image/webp', :webp

Related update in Rails adding webp as a valid content type for ActiveStorage rails/rails@2a0823e

Closes #3239

[Lookup the type ](https://apidock.com/rails/v6.0.0/Mime/Type/lookup_by_extension/class)via the [extension](https://apidock.com/rails/ActiveStorage/Filename/extension_without_delimiter), and match against 'image' types.

Rails provides a way to register custom mime types, allowing additional 'image' types to [be added to an Rails application](https://guides.rubyonrails.org/action_controller_overview.html#restful-downloads) without needing to maintain a list of specific filename extensions in `rails_admin`
@codealchemy codealchemy changed the title Update image? check for ActiveStorage fields Update image? check for file upload field types Sep 22, 2021
@mshibuya
Copy link
Member

Could add some tests, like webp is considered as an image?

`webp` is not currently a default configured image Mime::Type in Rails, so this includes a check where the application can register a type and RailsAdmin will render it accordingly.

This updates existing coverage as well to test against common image file types.
@mshibuya mshibuya merged commit 10d9c9d into railsadminteam:master Oct 2, 2021
@mshibuya
Copy link
Member

mshibuya commented Oct 2, 2021

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

webp support for image?
2 participants