diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-09-26 15:02:00 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2018-06-05 16:20:18 +0200 |
commit | 18d4f121d347bbc91f76b8112f797076864c6b33 (patch) | |
tree | de51c3b52e8c714ec708f0a4ff9de6b3f875b859 /app/uploaders | |
parent | ce6172e863f982c73fedc9f4a73877543c30cb1c (diff) | |
download | gitlab-ce-18d4f121d347bbc91f76b8112f797076864c6b33.tar.gz |
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).
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/favicon_uploader.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/app/uploaders/favicon_uploader.rb b/app/uploaders/favicon_uploader.rb index dc30e838337..b48ef770461 100644 --- a/app/uploaders/favicon_uploader.rb +++ b/app/uploaders/favicon_uploader.rb @@ -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 |