Skip to content

Commit

Permalink
Add WebP support (mastodon#9879)
Browse files Browse the repository at this point in the history
* Add WebP support

* Remove the changes to the tooltip

refs: mastodon#9879 (review)
  • Loading branch information
acid-chicken authored and Gargron committed Feb 2, 2019
1 parent b253d3e commit 5092d17
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/javascript/mastodon/utils/resize_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const loadImage = inputFile => new Promise((resolve, reject) => {
});

const getOrientation = (img, type = 'image/png') => new Promise(resolve => {
if (type !== 'image/jpeg') {
if (!['image/jpeg', 'image/webp'].includes(type)) {
resolve(1);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/account_avatar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module AccountAvatar
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

class_methods do
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/account_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module AccountHeader
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
MAX_PIXELS = 750_000 # 1500x500px

Expand Down
4 changes: 2 additions & 2 deletions app/models/media_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class MediaAttachment < ApplicationRecord

enum type: [:image, :gifv, :video, :unknown]

IMAGE_FILE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif'].freeze
IMAGE_FILE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp'].freeze
VIDEO_FILE_EXTENSIONS = ['.webm', '.mp4', '.m4v', '.mov'].freeze

IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
VIDEO_MIME_TYPES = ['video/webm', 'video/mp4', 'video/quicktime'].freeze
VIDEO_CONVERTIBLE_MIME_TYPES = ['video/webm', 'video/quicktime'].freeze

Expand Down
2 changes: 1 addition & 1 deletion app/models/preview_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#

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

self.inheritance_column = false
Expand Down

0 comments on commit 5092d17

Please sign in to comment.