mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-28 14:01:37 +01:00
1b5d26735e
* Revert "Adjust tags and accounts page (#4534)" This reverts commita3e53bd442
. * Revert "feat: Cache status height to avoid expensive renders (#4439)" This reverts commit8eb6d171e6
. * Revert "Refactor Avatar and AvatarOverlay to have 'account' as prop instead of src and staticSrc (#4526)" This reverts commit5942347407
. * Revert "Update dependencies for Ruby (#4543)" This reverts commit22db947225
. * Revert "[Docker] Add multicore support to "make" and "bundler" (#4544)" This reverts commit5d408fd9aa
. * Revert "It makes no sense to try using invalid or expired link again (#4521)" This reverts commit47579ec58c
. * Revert "i18n: Update Polish translation (#4545)" This reverts commit3363a05539
. * Revert "Set false to animated options for thumbnail processor (#4547)" This reverts commit87f10d476c
.
32 lines
847 B
Ruby
32 lines
847 B
Ruby
# frozen_string_literal: true
|
|
|
|
module AccountAvatar
|
|
extend ActiveSupport::Concern
|
|
|
|
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
|
|
|
class_methods do
|
|
def avatar_styles(file)
|
|
styles = { original: '120x120#' }
|
|
styles[:static] = { format: 'png' } if file.content_type == 'image/gif'
|
|
styles
|
|
end
|
|
|
|
private :avatar_styles
|
|
end
|
|
|
|
included do
|
|
# Avatar upload
|
|
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-quality 80 -strip' }
|
|
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
|
|
validates_attachment_size :avatar, less_than: 2.megabytes
|
|
end
|
|
|
|
def avatar_original_url
|
|
avatar.url(:original)
|
|
end
|
|
|
|
def avatar_static_url
|
|
avatar_content_type == 'image/gif' ? avatar.url(:static) : avatar_original_url
|
|
end
|
|
end
|