fix: use correct MIME types for image preview (#491)
This commit was merged in pull request #491.
This commit is contained in:
@@ -332,11 +332,21 @@ export function FileViewer({
|
|||||||
const getImageDataUrl = (content: string, fileName: string): string => {
|
const getImageDataUrl = (content: string, fileName: string): string => {
|
||||||
const ext = fileName.split(".").pop()?.toLowerCase() || "";
|
const ext = fileName.split(".").pop()?.toLowerCase() || "";
|
||||||
|
|
||||||
if (ext === "svg") {
|
const mimeTypes: Record<string, string> = {
|
||||||
return `data:image/svg+xml;base64,${content}`;
|
svg: "image/svg+xml",
|
||||||
}
|
png: "image/png",
|
||||||
|
jpg: "image/jpeg",
|
||||||
|
jpeg: "image/jpeg",
|
||||||
|
gif: "image/gif",
|
||||||
|
webp: "image/webp",
|
||||||
|
bmp: "image/bmp",
|
||||||
|
ico: "image/x-icon",
|
||||||
|
tiff: "image/tiff",
|
||||||
|
tif: "image/tiff",
|
||||||
|
};
|
||||||
|
|
||||||
return `data:image/*;base64,${content}`;
|
const mimeType = mimeTypes[ext] || "image/png";
|
||||||
|
return `data:${mimeType};base64,${content}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const WARNING_SIZE = 50 * 1024 * 1024;
|
const WARNING_SIZE = 50 * 1024 * 1024;
|
||||||
|
|||||||
Reference in New Issue
Block a user