2017-09-26 07:51:24 +00:00
|
|
|
class FaviconUploader < AttachmentUploader
|
2018-05-17 17:00:32 +00:00
|
|
|
EXTENSION_WHITELIST = %w[png ico].freeze
|
|
|
|
|
2017-09-26 07:51:24 +00:00
|
|
|
include CarrierWave::MiniMagick
|
|
|
|
|
2017-09-28 11:57:08 +00:00
|
|
|
version :favicon_main do
|
2017-09-26 07:51:24 +00:00
|
|
|
process resize_to_fill: [32, 32]
|
2017-12-06 20:04:53 +00:00
|
|
|
process convert: 'png'
|
2017-09-26 07:51:24 +00:00
|
|
|
|
2017-09-26 13:02:00 +00:00
|
|
|
def full_filename(filename)
|
2017-12-06 20:04:53 +00:00
|
|
|
filename_for_different_format(super(filename), 'png')
|
2017-09-26 07:51:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-27 13:03:49 +00:00
|
|
|
def extension_whitelist
|
2018-05-17 17:00:32 +00:00
|
|
|
EXTENSION_WHITELIST
|
2017-09-27 13:03:49 +00:00
|
|
|
end
|
|
|
|
|
2017-09-26 13:02:00 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def filename_for_different_format(filename, format)
|
|
|
|
filename.chomp(File.extname(filename)) + ".#{format}"
|
|
|
|
end
|
2017-09-26 07:51:24 +00:00
|
|
|
end
|