mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
prevent image loading and add image-off logo for code preview
This commit is contained in:
1 parent
766aea14b9
commit
e88b8c90d9
3 files changed
+64
-23
No files matched your search
@@ -67,4 +67,27 @@ export async function saveFileToTmp(fs: JSRuntimeFS, file: File, tmpPath = '/tmp
|
||||
await fs.writeFile(fullPath, uint8Array);
|
||||
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file path represents a media/binary file that cannot be edited as text
|
||||
* @param path - File path to check
|
||||
* @returns boolean - True if the file is a media/binary file
|
||||
*/
|
||||
export function isMediaFile(path: string): boolean {
|
||||
const extension = path.split('.').pop()?.toLowerCase();
|
||||
if (!extension) return false;
|
||||
|
||||
const mediaExtensions = [
|
||||
// Images
|
||||
'jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'ico', 'avif', 'heic', 'heif',
|
||||
// Videos
|
||||
'mp4', 'webm', 'avi', 'mov', 'mkv', 'flv', 'wmv', 'm4v',
|
||||
// Audio
|
||||
'mp3', 'wav', 'ogg', 'flac', 'm4a', 'aac', 'wma',
|
||||
// Other binary formats
|
||||
'pdf', 'zip', 'tar', 'gz', 'rar', '7z',
|
||||
];
|
||||
|
||||
return mediaExtensions.includes(extension);
|
||||
}
|
||||
Reference in new issue
Block a user