Permalink
Browse files

Allow whitelisting of mime types inside images validator.

  • Loading branch information...
1 parent 0e34bd0 commit a3af3dd0d1b06d64af4f360821921ec721bd1a51 @robyurkowski robyurkowski committed Mar 20, 2012
@@ -6,7 +6,7 @@ class Image < Refinery::Core::BaseModel
validates :image, :presence => true
validates_with ImageSizeValidator
- validates_property :mime_type, :of => :image, :in => %w(image/jpeg image/png image/gif image/tiff),
+ validates_property :mime_type, :of => :image, :in => ::Refinery::Images.whitelisted_mime_types,
:message => :incorrect_format
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
@@ -14,6 +14,9 @@ Refinery::Images.configure do |config|
# Configure image sizes
# config.user_image_sizes = <%= Refinery::Images.user_image_sizes.inspect %>
+
+ # Configure white-listed mime types for validation
+ # config.whitelisted_mime_types = <%= Refinery::Images.whitelisted_mime_types.inspect %>
# Configure image view options
# config.image_views = <%= Refinery::Images.image_views.inspect %>
@@ -7,7 +7,8 @@ module Images
:pages_per_dialog_that_have_size_options, :user_image_sizes,
:image_views, :preferred_image_view, :datastore_root_path,
:s3_backend, :s3_bucket_name, :s3_region,
- :s3_access_key_id, :s3_secret_access_key, :trust_file_extensions
+ :s3_access_key_id, :s3_secret_access_key, :trust_file_extensions,
+ :whitelisted_mime_types
self.dragonfly_insert_before = 'ActionDispatch::Callbacks'
self.dragonfly_secret = Refinery::Core.dragonfly_secret
@@ -24,6 +25,14 @@ module Images
:medium => '225x255>',
:large => '450x450>'
}
+
+ self.whitelisted_mime_types = [
+ 'image/jpeg',
+ 'image/png',
+ 'image/gif',
+ 'image/tiff'
+ ]
+
self.image_views = [:grid, :list]
self.preferred_image_view = :grid

0 comments on commit a3af3dd

Please sign in to comment.