Fix #5065: .webp images upload support
Add ability to upload .webp images. Animated WebP images aren't supported. This is because they aren't supported by FFmpeg yet[1], so generating thumbnails and samples for them would be more complicated than for other formats. [1]: https://trac.ffmpeg.org/ticket/4907
This commit is contained in:
@@ -26,7 +26,7 @@ class MediaFile
|
||||
file = Kernel.open(file, "r", binmode: true) unless file.respond_to?(:read)
|
||||
|
||||
case file_ext(file)
|
||||
when :jpg, :gif, :png, :avif
|
||||
when :jpg, :gif, :png, :webp, :avif
|
||||
MediaFile::Image.new(file, **options)
|
||||
when :swf
|
||||
MediaFile::Flash.new(file, **options)
|
||||
@@ -62,6 +62,10 @@ class MediaFile
|
||||
when /\A\x1a\x45\xdf\xa3/n
|
||||
:webm
|
||||
|
||||
# https://developers.google.com/speed/webp/docs/riff_container
|
||||
when /\ARIFF....WEBP/
|
||||
:webp
|
||||
|
||||
# https://www.ftyps.com
|
||||
# isom (common) - MP4 Base Media v1 [IS0 14496-12:2003]
|
||||
# mp42 (common) - MP4 v2 [ISO 14496-14]
|
||||
@@ -144,7 +148,7 @@ class MediaFile
|
||||
|
||||
# @return [Boolean] true if the file is an image
|
||||
def is_image?
|
||||
file_ext.in?([:jpg, :png, :gif, :avif])
|
||||
file_ext.in?(%i[jpg png gif webp avif])
|
||||
end
|
||||
|
||||
# @return [Boolean] true if the file is a video
|
||||
|
||||
Reference in New Issue
Block a user