diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 12d4c809c..eed654f14 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -227,7 +227,7 @@ class Attachment < ApplicationRecord end def image? - !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|webp)$/i) + !!(self.filename =~ /\.(avif|bmp|gif|jpg|jpe|jpeg|png|webp)$/i) end def thumbnailable? diff --git a/lib/redmine/mime_type.rb b/lib/redmine/mime_type.rb index 5554cc5a9..170264715 100644 --- a/lib/redmine/mime_type.rb +++ b/lib/redmine/mime_type.rb @@ -39,6 +39,7 @@ module Redmine 'text/yaml' => 'yml,yaml', 'text/csv' => 'csv', 'text/x-po' => 'po', + 'image/avif' => 'avif', 'image/gif' => 'gif', 'image/jpeg' => 'jpg,jpeg,jpe', 'image/png' => 'png', diff --git a/lib/redmine/thumbnail.rb b/lib/redmine/thumbnail.rb index 556680a5a..df1612dc8 100644 --- a/lib/redmine/thumbnail.rb +++ b/lib/redmine/thumbnail.rb @@ -30,7 +30,7 @@ module Redmine ('gswin64c' if Redmine::Platform.mswin?) || 'gs' ).freeze - ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png image/webp application/pdf) + ALLOWED_TYPES = %w(image/avif image/bmp image/gif image/jpeg image/png image/webp application/pdf) # Generates a thumbnail for the source image to target # TODO: Remove the deprecated _is_pdf parameter in Redmine 7.0 diff --git a/lib/redmine/wiki_formatting/inline_attachments_scrubber.rb b/lib/redmine/wiki_formatting/inline_attachments_scrubber.rb index 2da380df7..64b0cc88e 100644 --- a/lib/redmine/wiki_formatting/inline_attachments_scrubber.rb +++ b/lib/redmine/wiki_formatting/inline_attachments_scrubber.rb @@ -51,7 +51,7 @@ module Redmine src = node['src'] - if src =~ %r{\A(?[^/"]+?\.(?:bmp|gif|jpg|jpeg|jpe|png|webp))\z}i + if src =~ %r{\A(?[^/"]+?\.(?:avif|bmp|gif|jpg|jpeg|jpe|png|webp))\z}i filename = $~[:filename] if found = find_attachment(CGI.unescape(filename)) image_url = @view.download_named_attachment_url(found, found.filename, :only_path => @only_path) diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 1af8eb0f2..387da73c5 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -520,6 +520,7 @@ class AttachmentTest < ActiveSupport::TestCase def test_thumbnailable_should_be_true_for_images skip unless convert_installed? + assert_equal true, Attachment.new(:filename => 'test.avif').thumbnailable? assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable? assert_equal true, Attachment.new(:filename => 'test.webp').thumbnailable? end diff --git a/test/unit/lib/redmine/mime_type_test.rb b/test/unit/lib/redmine/mime_type_test.rb index 95aaef034..265146462 100644 --- a/test/unit/lib/redmine/mime_type_test.rb +++ b/test/unit/lib/redmine/mime_type_test.rb @@ -24,6 +24,7 @@ class Redmine::MimeTypeTest < ActiveSupport::TestCase to_test = { 'test.txt' => 'text/plain', 'test.c' => 'text/x-c', + 'test.avif' => 'image/avif', 'TEST.JPG' => 'image/jpeg', } to_test.each do |name, expected| @@ -79,6 +80,7 @@ class Redmine::MimeTypeTest < ActiveSupport::TestCase def test_by_type image_types = Redmine::MimeType.by_type('image') + assert_includes image_types, 'image/avif' assert_includes image_types, 'image/png' assert_includes image_types, 'image/webp' end diff --git a/test/unit/lib/redmine/wiki_formatting/inline_attachments_scrubber_test.rb b/test/unit/lib/redmine/wiki_formatting/inline_attachments_scrubber_test.rb index 2c441c0e5..278a4c7c5 100644 --- a/test/unit/lib/redmine/wiki_formatting/inline_attachments_scrubber_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/inline_attachments_scrubber_test.rb @@ -35,6 +35,7 @@ class Redmine::WikiFormatting::InlineAttachmentsScrubberTest < Redmine::HelperTe def test_should_resolve_attached_images to_test = [ + "test.avif", "test.bmp", "test.gif", "test.jpg",