Context: it seems image/webp is not part of the standard hash of extensions to mime types in Dragonfly, and browsers read the content type as "octet-stream". Dragonfly.app.mime_types in the Rails console returns everything under the sun except image/webp. So whitelisting it in the refinery initializers doesn't work because Dragonfly won't find it to begin with (change the extension to almost anything else, and it will work).
I assume it's this issue that the array of additional mime type in the initializer (config/initializers/refinery/dragonfly.rb) is meant to solve?
But I can't find a way to register mime types that will actually be picked up by refinerycms-images. I've tried putting a Dragonfly compatible hash inside the refinery dragonfly initializers, and although it seems like it's picked up by the Refinery::Dragonfly module, it still doesn't work.
This is what I'm trying to do:
diff --git a/config/initializers/refinery/dragonfly.rb b/config/initializers/refinery/dragonfly.rb
index 0920e0ce..daec5121 100644
--- a/config/initializers/refinery/dragonfly.rb
+++ b/config/initializers/refinery/dragonfly.rb
@@ -21,7 +21,7 @@ Refinery::Dragonfly.configure do |config|
# config.fetch_file_whitelist = nil
# config.fetch_url_whitelist = nil
# config.generators = []
- # config.mime_types = []
+ config.mime_types = [".webp" => "image/webp"]
# config.name = "dragonfly"
# config.path_prefix = nil
# config.plugin = "libvips"
diff --git a/config/initializers/refinery/images.rb b/config/initializers/refinery/images.rb
index 241d56da..438fa266 100644
--- a/config/initializers/refinery/images.rb
+++ b/config/initializers/refinery/images.rb
@@ -18,7 +18,7 @@ Refinery::Images.configure do |config|
# config.user_image_sizes = {:small=>"110x110>", :medium=>"225x255>", :large=>"450x450>"}
# Configure white-listed mime types for validation
- # config.whitelisted_mime_types = ["image/jpeg", "image/png", "image/gif", "image/tiff"]
+ config.whitelisted_mime_types = ["image/jpeg", "image/webp" "image/png", "image/gif", "image/tiff"]
# Configure image view options
# config.image_views = [:grid, :list]
Is this a bug, or am I holding it wrong?
Context: it seems
image/webpis not part of the standard hash of extensions to mime types in Dragonfly, and browsers read the content type as "octet-stream".Dragonfly.app.mime_typesin the Rails console returns everything under the sun exceptimage/webp. So whitelisting it in the refinery initializers doesn't work because Dragonfly won't find it to begin with (change the extension to almost anything else, and it will work).I assume it's this issue that the array of additional mime type in the initializer (
config/initializers/refinery/dragonfly.rb) is meant to solve?But I can't find a way to register mime types that will actually be picked up by refinerycms-images. I've tried putting a Dragonfly compatible hash inside the refinery dragonfly initializers, and although it seems like it's picked up by the
Refinery::Dragonflymodule, it still doesn't work.This is what I'm trying to do:
Is this a bug, or am I holding it wrong?