mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-19 13:47:35 +00:00
1899cf5f04
* Detect extension for preview card * next
22 lines
610 B
Ruby
22 lines
610 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Attachmentable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
before_post_process :set_file_extensions
|
|
end
|
|
|
|
private
|
|
|
|
def set_file_extensions
|
|
self.class.attachment_definitions.each_key do |attachment_name|
|
|
attachment = send(attachment_name)
|
|
next if attachment.blank?
|
|
extension = Paperclip::Interpolations.content_type_extension(attachment, :original)
|
|
basename = Paperclip::Interpolations.basename(attachment, :original)
|
|
attachment.instance_write :file_name, [basename, extension].delete_if(&:empty?).join('.')
|
|
end
|
|
end
|
|
end
|