Skip to content

Commit

Permalink
Register webp as mime type
Browse files Browse the repository at this point in the history
Rails 6.1.5 does not have a image/webp mime type registered.
  • Loading branch information
tvdeyen committed Mar 28, 2022
1 parent b6d22a8 commit 25cc942
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/alchemy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,16 @@ class Engine < Rails::Engine
end
end
end

initializer "alchemy.webp-mime_type" do
# Rails does not know anything about webp even in 2022
unless Mime::Type.lookup_by_extension(:webp)
Mime::Type.register("image/webp", :webp)
end
# Dragonfly uses Rack to read the mime type and guess what
unless Rack::Mime::MIME_TYPES[".webp"]
Rack::Mime::MIME_TYPES[".webp"] = "image/webp"
end
end
end
end

0 comments on commit 25cc942

Please sign in to comment.