Skip to content
Snippets Groups Projects
  • Yamagishi Kazutoshi's avatar
    1b5d2673
    Revert "Set false to animated options for thumbnail processor" (#4550) · 1b5d2673
    Yamagishi Kazutoshi authored
    * Revert "Adjust tags and accounts page (#4534)"
    
    This reverts commit a3e53bd4.
    
    * Revert "feat: Cache status height to avoid expensive renders (#4439)"
    
    This reverts commit 8eb6d171.
    
    * Revert "Refactor Avatar and AvatarOverlay to have 'account' as prop instead of src and staticSrc (#4526)"
    
    This reverts commit 59423474.
    
    * Revert "Update dependencies for Ruby (#4543)"
    
    This reverts commit 22db9472.
    
    * Revert "[Docker] Add multicore support to "make" and "bundler" (#4544)"
    
    This reverts commit 5d408fd9.
    
    * Revert "It makes no sense to try using invalid or expired link again (#4521)"
    
    This reverts commit 47579ec5.
    
    * Revert "i18n: Update Polish translation (#4545)"
    
    This reverts commit 3363a055.
    
    * Revert "Set false to animated options for thumbnail processor (#4547)"
    
    This reverts commit 87f10d47.
    1b5d2673
    History
    Revert "Set false to animated options for thumbnail processor" (#4550)
    Yamagishi Kazutoshi authored
    * Revert "Adjust tags and accounts page (#4534)"
    
    This reverts commit a3e53bd4.
    
    * Revert "feat: Cache status height to avoid expensive renders (#4439)"
    
    This reverts commit 8eb6d171.
    
    * Revert "Refactor Avatar and AvatarOverlay to have 'account' as prop instead of src and staticSrc (#4526)"
    
    This reverts commit 59423474.
    
    * Revert "Update dependencies for Ruby (#4543)"
    
    This reverts commit 22db9472.
    
    * Revert "[Docker] Add multicore support to "make" and "bundler" (#4544)"
    
    This reverts commit 5d408fd9.
    
    * Revert "It makes no sense to try using invalid or expired link again (#4521)"
    
    This reverts commit 47579ec5.
    
    * Revert "i18n: Update Polish translation (#4545)"
    
    This reverts commit 3363a055.
    
    * Revert "Set false to animated options for thumbnail processor (#4547)"
    
    This reverts commit 87f10d47.
account_header.rb 847 B
# frozen_string_literal: true

module AccountHeader
  extend ActiveSupport::Concern

  IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze

  class_methods do
    def header_styles(file)
      styles = { original: '700x335#' }
      styles[:static] = { format: 'png' } if file.content_type == 'image/gif'
      styles
    end

    private :header_styles
  end

  included do
    # Header upload
    has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '-quality 80 -strip' }
    validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES
    validates_attachment_size :header, less_than: 2.megabytes
  end

  def header_original_url
    header.url(:original)
  end

  def header_static_url
    header_content_type == 'image/gif' ? header.url(:static) : header_original_url
  end
end