mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Support AVIF (#2630)
This commit is contained in:
parent
25cab1c67a
commit
9d3f01043b
5 changed files with 5 additions and 3 deletions
|
@ -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>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue