mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-22 12:58:06 +01:00
Revert "Allow adjusting avatar sizes (local and remote) via config"
This reverts commit df02b66295
.
This commit is contained in:
parent
df02b66295
commit
554ac88290
3 changed files with 2 additions and 12 deletions
|
@ -40,5 +40,4 @@ MAX_DISPLAY_NAME_CHARS=50
|
||||||
MAX_POLL_OPTIONS=20
|
MAX_POLL_OPTIONS=20
|
||||||
MAX_SEARCH_RESULTS=1000
|
MAX_SEARCH_RESULTS=1000
|
||||||
MAX_REMOTE_EMOJI_SIZE=1048576
|
MAX_REMOTE_EMOJI_SIZE=1048576
|
||||||
# MAX_REMOTE_AVATAR_SIZE=4194304
|
|
||||||
IP_RETENTION_PERIOD=86400
|
IP_RETENTION_PERIOD=86400
|
||||||
|
|
|
@ -286,13 +286,6 @@ MAX_POLL_OPTION_CHARS=100
|
||||||
# MAX_EMOJI_SIZE=262144
|
# MAX_EMOJI_SIZE=262144
|
||||||
# MAX_REMOTE_EMOJI_SIZE=262144
|
# MAX_REMOTE_EMOJI_SIZE=262144
|
||||||
|
|
||||||
# Maximum avatar (upload) sizes
|
|
||||||
# If undefined or smaller than MAX_AVATAR_SIZE, the value
|
|
||||||
# of MAX_AVATAR_SIZE will be used for MAX_REMOTE_AVATAR_SIZE
|
|
||||||
# Units are in bytes
|
|
||||||
# MAX_AVATAR_SIZE=2097152
|
|
||||||
# MAX_REMOTE_AVATAR_SIZE=2097152
|
|
||||||
|
|
||||||
# Optional hCaptcha support
|
# Optional hCaptcha support
|
||||||
# HCAPTCHA_SECRET_KEY=
|
# HCAPTCHA_SECRET_KEY=
|
||||||
# HCAPTCHA_SITE_KEY=
|
# HCAPTCHA_SITE_KEY=
|
||||||
|
|
|
@ -4,8 +4,7 @@ module AccountAvatar
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||||
LOCAL_LIMIT = (ENV['MAX_AVATAR_SIZE'] || 2.megabytes).to_i
|
LIMIT = 2.megabytes
|
||||||
LIMIT = [LOCAL_LIMIT, (ENV['MAX_REMOTE_AVATAR_SIZE'] || 2.megabytes).to_i].max
|
|
||||||
|
|
||||||
class_methods do
|
class_methods do
|
||||||
def avatar_styles(file)
|
def avatar_styles(file)
|
||||||
|
@ -21,8 +20,7 @@ module AccountAvatar
|
||||||
# Avatar upload
|
# Avatar upload
|
||||||
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
|
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
|
||||||
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
|
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
|
||||||
validates_attachment_size :avatar, less_than: LIMIT, unless: :local?
|
validates_attachment_size :avatar, less_than: LIMIT
|
||||||
validates_attachment_size :avatar, less_than: LOCAL_LIMIT, if: :local?
|
|
||||||
remotable_attachment :avatar, LIMIT, suppress_errors: false
|
remotable_attachment :avatar, LIMIT, suppress_errors: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue