diff --git a/app/helpers/favicon_helper.rb b/app/helpers/favicon_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..3a5342a8d9d4cb388c889c11f3501f13dba36cac --- /dev/null +++ b/app/helpers/favicon_helper.rb @@ -0,0 +1,7 @@ +module FaviconHelper + def favicon_extension_whitelist + FaviconUploader::EXTENSION_WHITELIST + .map { |extension| "'.#{extension}'"} + .to_sentence + end +end diff --git a/app/uploaders/favicon_uploader.rb b/app/uploaders/favicon_uploader.rb index aa4c78da7a6b580bef246132a593cd26e1e963fc..09afc63a5aad8cfa41a01820fa1bc901305adc9b 100644 --- a/app/uploaders/favicon_uploader.rb +++ b/app/uploaders/favicon_uploader.rb @@ -1,4 +1,6 @@ class FaviconUploader < AttachmentUploader + EXTENSION_WHITELIST = %w[png ico].freeze + include CarrierWave::MiniMagick version :favicon_main do @@ -11,7 +13,7 @@ class FaviconUploader < AttachmentUploader end def extension_whitelist - %w[png ico] + EXTENSION_WHITELIST end private diff --git a/app/views/admin/appearances/_form.html.haml b/app/views/admin/appearances/_form.html.haml index b44c006a459f347fcbc0e4ba03dc6b64d4b65f28..2e48364b94a7692afc1496524f6788cb92bcd618 100644 --- a/app/views/admin/appearances/_form.html.haml +++ b/app/views/admin/appearances/_form.html.haml @@ -72,7 +72,9 @@ = f.hidden_field :favicon_cache = f.file_field :favicon, class: '' .hint - Maximum file size is 1MB. The resulting favicons will be cropped to be square and scaled down to a size of 32x32 px. + Maximum file size is 1MB. Allowed image formats are #{favicon_extension_whitelist}. + %br + The resulting favicons will be cropped to be square and scaled down to a size of 32x32 px. .form-actions = f.submit 'Save', class: 'btn btn-save append-right-10'