Support AVIF (#2630)

This commit is contained in:
Nil Admirari 2023-08-30 22:44:10 +00:00 committed by GitHub
parent 25cab1c67a
commit 9d3f01043b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 3 deletions

View file

@ -135,6 +135,7 @@ Kehinde Adeleke <adelekekehinde06@gmail.com>
Marko Juhanne <github.com/mjuhanne> Marko Juhanne <github.com/mjuhanne>
Gabriel Heinatz <anorot@gmail.com> Gabriel Heinatz <anorot@gmail.com>
Monty Evans <montyevans@gmail.com> Monty Evans <montyevans@gmail.com>
Nil Admirari <https://github.com/nihil-admirari>
******************** ********************

View file

@ -116,6 +116,7 @@ class MediaManager(DeprecatedNamesMixin):
"image/png": ".png", "image/png": ".png",
"image/svg+xml": ".svg", "image/svg+xml": ".svg",
"image/webp": ".webp", "image/webp": ".webp",
"image/avif": ".avif",
} }
if content_type in type_map: if content_type in type_map:
fname += type_map[content_type] fname += type_map[content_type]

View file

@ -58,7 +58,7 @@ from aqt.utils import (
) )
from aqt.webview import AnkiWebView, AnkiWebViewKind from aqt.webview import AnkiWebView, AnkiWebViewKind
pics = ("jpg", "jpeg", "png", "tif", "tiff", "gif", "svg", "webp", "ico") pics = ("jpg", "jpeg", "png", "tif", "tiff", "gif", "svg", "webp", "ico", "avif")
audio = ( audio = (
"3gp", "3gp",
"aac", "aac",

View file

@ -142,7 +142,7 @@ impl Collection {
fn is_image_file(&mut self, path: &PathBuf) -> Result<bool> { fn is_image_file(&mut self, path: &PathBuf) -> Result<bool> {
let file_path = Path::new(&path); let file_path = Path::new(&path);
let supported_extensions = [ let supported_extensions = [
"jpg", "jpeg", "png", "tif", "tiff", "gif", "svg", "webp", "ico", "jpg", "jpeg", "png", "tif", "tiff", "gif", "svg", "webp", "ico", "avif",
]; ];
if file_path.exists() { if file_path.exists() {

View file

@ -453,7 +453,7 @@ impl MediaChecker<'_> {
fn maybe_extract_inline_image<'a>(&mut self, fname_decoded: &'a str) -> Result<Cow<'a, str>> { fn maybe_extract_inline_image<'a>(&mut self, fname_decoded: &'a str) -> Result<Cow<'a, str>> {
static BASE64_IMG: Lazy<Regex> = Lazy::new(|| { static BASE64_IMG: Lazy<Regex> = Lazy::new(|| {
Regex::new("(?i)^data:image/(jpg|jpeg|png|gif|webp);base64,(.+)$").unwrap() Regex::new("(?i)^data:image/(jpg|jpeg|png|gif|webp|avif);base64,(.+)$").unwrap()
}); });
let Some(caps) = BASE64_IMG.captures(fname_decoded) else { let Some(caps) = BASE64_IMG.captures(fname_decoded) else {