From 80c44ed9c19855d494ab26011dca0f6fbc644d0c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 4 Dec 2016 12:26:12 +0100 Subject: Do not autoplay videos, display play button instead. Use expiring links when using S3. Do not keep originals for avatars/headers, resize avatars down to 120x120 instead of 300x300. Set cache headers on S3 stuff, also make it private (aka only accessible via expiring links to prevent hotlinking) --- app/models/account.rb | 4 ++-- app/models/media_attachment.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index 105b77e04..b1cf34e9a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -13,12 +13,12 @@ class Account < ApplicationRecord validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?' # Avatar upload - has_attached_file :avatar, styles: { large: '300x300#' }, convert_options: { all: '-strip' } + has_attached_file :avatar, styles: { original: '120x120#' }, convert_options: { all: '-quality 80 -strip' } validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES validates_attachment_size :avatar, less_than: 2.megabytes # Header upload - has_attached_file :header, styles: { medium: '700x335#' }, convert_options: { all: '-strip' } + has_attached_file :header, styles: { original: '700x335#' }, convert_options: { all: '-quality 80 -strip' } validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES validates_attachment_size :header, less_than: 2.megabytes diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index f1b9b8112..d37ef99a8 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -10,7 +10,7 @@ class MediaAttachment < ApplicationRecord has_attached_file :file, styles: -> (f) { file_styles f }, processors: -> (f) { f.video? ? [:transcoder] : [:thumbnail] }, - convert_options: { all: '-strip' } + convert_options: { all: '-quality 80 -strip' } validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES validates_attachment_size :file, less_than: 4.megabytes -- cgit