diff options
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/favicon_uploader.rb | 24 | ||||
-rw-r--r-- | app/uploaders/uploader_helper.rb | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/app/uploaders/favicon_uploader.rb b/app/uploaders/favicon_uploader.rb new file mode 100644 index 00000000000..09afc63a5aa --- /dev/null +++ b/app/uploaders/favicon_uploader.rb @@ -0,0 +1,24 @@ +class FaviconUploader < AttachmentUploader + EXTENSION_WHITELIST = %w[png ico].freeze + + include CarrierWave::MiniMagick + + version :favicon_main do + process resize_to_fill: [32, 32] + process convert: 'png' + + def full_filename(filename) + filename_for_different_format(super(filename), 'png') + end + end + + def extension_whitelist + EXTENSION_WHITELIST + end + + private + + def filename_for_different_format(filename, format) + filename.chomp(File.extname(filename)) + ".#{format}" + end +end diff --git a/app/uploaders/uploader_helper.rb b/app/uploaders/uploader_helper.rb index fd446d31092..207928b61d0 100644 --- a/app/uploaders/uploader_helper.rb +++ b/app/uploaders/uploader_helper.rb @@ -1,6 +1,6 @@ # Extra methods for uploader module UploaderHelper - IMAGE_EXT = %w[png jpg jpeg gif bmp tiff].freeze + IMAGE_EXT = %w[png jpg jpeg gif bmp tiff ico].freeze # We recommend using the .mp4 format over .mov. Videos in .mov format can # still be used but you really need to make sure they are served with the # proper MIME type video/mp4 and not video/quicktime or your videos won't play |