Commit 18d4f121 authored by Alexis Reigel's avatar Alexis Reigel

fix carrierwave suffix for different format

when versions have a different file format from the original file
carrierwave constructs a wrong url (with the original file suffix).
parent ce6172e8
......@@ -14,24 +14,27 @@ class FaviconUploader < AttachmentUploader
:status_running
].freeze
version :default_without_format_conversion do
version :default do
process resize_to_fill: [32, 32]
end
# this intermediate version generates an image in the ico format but with the
# original file suffix.
version :_default, from_version: :default_without_format_conversion do
process convert: 'ico'
end
version :default, from_version: :_default
def full_filename(filename)
filename_for_different_format(super(filename), 'ico')
end
end
STATUS_ICON_NAMES.each do |status_name|
version status_name, from_version: :default do
process status_favicon: status_name
def full_filename(filename)
filename_for_different_format(super(filename), 'ico')
end
end
end
private
def status_favicon(status_name)
manipulate! do |img|
overlay_path = Rails.root.join("app/assets/images/ci_favicons/overlays/favicon_#{status_name}.png")
......@@ -41,4 +44,8 @@ class FaviconUploader < AttachmentUploader
end
end
end
def filename_for_different_format(filename, format)
filename.chomp(File.extname(filename)) + ".#{format}"
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment