Feature #43943 ยป 0001-Support-AVIF-images.patch
| app/models/attachment.rb | ||
|---|---|---|
|
end
|
||
|
def image?
|
||
|
!!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|webp)$/i)
|
||
|
!!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|avif|webp)$/i)
|
||
|
end
|
||
|
def thumbnailable?
|
||
| lib/redmine/mime_type.rb | ||
|---|---|---|
|
'image/jpeg' => 'jpg,jpeg,jpe',
|
||
|
'image/png' => 'png',
|
||
|
'image/tiff' => 'tiff,tif',
|
||
|
'image/avif' => 'avif',
|
||
|
'image/webp' => 'webp',
|
||
|
'image/x-ms-bmp' => 'bmp',
|
||
|
'application/javascript' => 'js',
|
||
| lib/redmine/thumbnail.rb | ||
|---|---|---|
|
('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/bmp image/gif image/jpeg image/png image/avif image/webp application/pdf)
|
||
|
# Generates a thumbnail for the source image to target
|
||
|
# TODO: Remove the deprecated _is_pdf parameter in Redmine 7.0
|
||
| lib/redmine/wiki_formatting/inline_attachments_scrubber.rb | ||
|---|---|---|
|
src = node['src']
|
||
|
if src =~ %r{\A(?<filename>[^/"]+?\.(?:bmp|gif|jpg|jpeg|jpe|png|webp))\z}i
|
||
|
if src =~ %r{\A(?<filename>[^/"]+?\.(?:bmp|gif|jpg|jpeg|jpe|png|avif|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)
|
||
| test/unit/attachment_test.rb | ||
|---|---|---|
|
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
|
||
| test/unit/lib/redmine/mime_type_test.rb | ||
|---|---|---|
|
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|
|
||
| ... | ... | |
|
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
|
||
| test/unit/lib/redmine/wiki_formatting/inline_attachments_scrubber_test.rb | ||
|---|---|---|
|
"test.jpeg",
|
||
|
"test.jpe",
|
||
|
"test.png",
|
||
|
"test.avif",
|
||
|
"test.webp"
|
||
|
]
|
||