Convert blob icons to base64 without canvas

This commit is contained in:
Dustin Brett 2024-08-14 22:25:46 -07:00
parent 51b9209500
commit bc74b13cfa

View File

@ -54,6 +54,7 @@ import {
VIDEO_FILE_EXTENSIONS,
} from "utils/constants";
import {
blobToBase64,
bufferToUrl,
getExtension,
getFormattedSize,
@ -333,9 +334,16 @@ const FileEntry: FC<FileEntryProps> = ({
if (
iconRef.current.currentSrc.startsWith(
"data:image/gif;base64,"
) ||
iconRef.current.currentSrc.startsWith(
"data:image/png;base64,"
)
) {
generatedIcon = iconRef.current.currentSrc;
} else if (iconRef.current.currentSrc.startsWith("blob:")) {
generatedIcon = await blobToBase64(
await (await fetch(iconRef.current.currentSrc)).blob()
);
} else {
const { clientHeight, clientWidth } = iconRef.current;
const { naturalHeight, naturalWidth } = iconRef.current;