Extract constants for header and avatar geometry (#32151)
This commit is contained in:
parent
c009507912
commit
ec16ed37c3
3 changed files with 11 additions and 5 deletions
|
@ -6,10 +6,13 @@ module Account::Avatar
|
|||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
|
||||
AVATAR_DIMENSIONS = [400, 400].freeze
|
||||
AVATAR_GEOMETRY = [AVATAR_DIMENSIONS.first, AVATAR_DIMENSIONS.last].join('x')
|
||||
|
||||
class_methods do
|
||||
def avatar_styles(file)
|
||||
styles = { original: { geometry: '400x400#', file_geometry_parser: FastGeometryParser } }
|
||||
styles[:static] = { geometry: '400x400#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
|
||||
styles = { original: { geometry: "#{AVATAR_GEOMETRY}#", file_geometry_parser: FastGeometryParser } }
|
||||
styles[:static] = { geometry: "#{AVATAR_GEOMETRY}#", format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
|
||||
styles
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ module Account::Header
|
|||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
MAX_PIXELS = 750_000 # 1500x500px
|
||||
|
||||
HEADER_DIMENSIONS = [1500, 500].freeze
|
||||
HEADER_GEOMETRY = [HEADER_DIMENSIONS.first, HEADER_DIMENSIONS.last].join('x')
|
||||
MAX_PIXELS = HEADER_DIMENSIONS.first * HEADER_DIMENSIONS.last
|
||||
|
||||
class_methods do
|
||||
def header_styles(file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue