feat: media page T1
This commit is contained in:
1 parent
67d456baf6
commit
008b0dfbb9
46 files changed
+5742
-204
No files matched your search
@@ -27,6 +27,17 @@ export function validateImageFile(file: File): ImageValidationResult {
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
const EXTENSIONS_BY_MIME_TYPE: Record<string, string[]> = {
|
||||
'image/png': ['.png'],
|
||||
'image/jpeg': ['.jpg', '.jpeg'],
|
||||
'image/webp': ['.webp'],
|
||||
'image/svg+xml': ['.svg'],
|
||||
}
|
||||
|
||||
export function extensionMatchesType(file: File) {
|
||||
return EXTENSIONS_BY_MIME_TYPE[file.type]?.includes(fileExtension(file.name)) ?? false
|
||||
}
|
||||
|
||||
export function formatMegabytes(bytes: number) {
|
||||
return (bytes / (1024 * 1024)).toFixed(1)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user