Add WebP support

This commit is contained in:
noellabo 2021-11-25 10:17:40 +09:00
parent 28b9828f06
commit 752bd558ed
5 changed files with 5 additions and 5 deletions

View file

@ -109,7 +109,7 @@ const loadImage = inputFile => new Promise((resolve, reject) => {
}); });
const getOrientation = (img, type = 'image/png') => new Promise(resolve => { const getOrientation = (img, type = 'image/png') => new Promise(resolve => {
if (type !== 'image/jpeg') { if (!['image/jpeg', 'image/webp'].includes(type)) {
resolve(1); resolve(1);
return; return;
} }

View file

@ -3,7 +3,7 @@
module AccountAvatar module AccountAvatar
extend ActiveSupport::Concern extend ActiveSupport::Concern
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
LIMIT = 2.megabytes LIMIT = 2.megabytes
class_methods do class_methods do

View file

@ -3,7 +3,7 @@
module AccountHeader module AccountHeader
extend ActiveSupport::Concern extend ActiveSupport::Concern
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
LIMIT = 4.megabytes LIMIT = 4.megabytes
MAX_PIXELS = 750_000 # 1500x500px MAX_PIXELS = 750_000 # 1500x500px

View file

@ -29,7 +29,7 @@ class CustomEmoji < ApplicationRecord
:(#{SHORTCODE_RE_FRAGMENT}): :(#{SHORTCODE_RE_FRAGMENT}):
(?=[^[:alnum:]:]|$)/x (?=[^[:alnum:]:]|$)/x
IMAGE_MIME_TYPES = %w(image/png image/gif).freeze IMAGE_MIME_TYPES = %w(image/png image/gif image/webp).freeze
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode

View file

@ -27,7 +27,7 @@
# #
class PreviewCard < ApplicationRecord class PreviewCard < ApplicationRecord
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
LIMIT = 1.megabytes LIMIT = 1.megabytes
BLURHASH_OPTIONS = { BLURHASH_OPTIONS = {