From: Eugen Rochko Date: Sun, 5 Mar 2017 22:03:49 +0000 (+0100) Subject: Make the paperclip filename interpolator smarter about the :original style X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=ebc01bf0f61e58648ea7bfd4c915b4f373761e1d;p=mastodon.git Make the paperclip filename interpolator smarter about the :original style If an :original gets converted into another format, it would get saved as original_filename *anyway*, so generating the extension is pointless and yields bad results for when you change the style definition later. This way, old gifs will still have correct URLs --- diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 71a7b514e..580a3196e 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -2,6 +2,11 @@ Paperclip.options[:read_timeout] = 60 +Paperclip.interpolates :filename do |attachment, style| + return attachment.original_filename if style == :original + [basename(attachment, style), extension(attachment, style)].delete_if(&:empty?).join('.') +end + if ENV['S3_ENABLED'] == 'true' Aws.eager_autoload!(services: %w(S3))