media: added more mime types, added mime type check on dropzone

This commit is contained in:
dswbx
2025-02-22 13:14:32 +01:00
parent 837b0a3d43
commit f801d3a556
8 changed files with 99 additions and 24 deletions

View File

@@ -1,7 +1,7 @@
export const Q = {
video: ["mp4", "webm"],
audio: ["ogg"],
image: ["jpeg", "png", "gif", "webp", "bmp", "tiff"],
image: ["jpeg", "png", "gif", "webp", "bmp", "tiff", "avif", "heic", "heif"],
text: ["html", "css", "mdx", "yaml", "vcard", "csv", "vtt"],
application: ["zip", "xml", "toml", "json", "json5"],
font: ["woff", "woff2", "ttf", "otf"]
@@ -76,7 +76,8 @@ export function guess(f: string): string {
}
}
export function isMimeType(mime: any, exclude: string[] = []) {
export function isMimeType(_mime: any, exclude: string[] = []) {
const mime = _mime.toLowerCase();
if (exclude.includes(mime)) return false;
// try quick first
@@ -96,7 +97,9 @@ export function isMimeType(mime: any, exclude: string[] = []) {
return false;
}
export function extension(mime: string) {
export function extension(_mime: string) {
const mime = _mime.toLowerCase();
for (const [t, e] of Object.entries(Q)) {
for (const _e of e) {
if (mime === `${t}/${_e}`) {

View File

@@ -5,7 +5,7 @@ export function getExtensionFromName(filename: string): string | undefined {
if (!filename.includes(".")) return;
const parts = filename.split(".");
return parts[parts.length - 1];
return parts[parts.length - 1]?.toLowerCase();
}
export function getRandomizedFilename(file: File, length?: number): string;