Closed mProjectsCode closed 3 months ago
Ah, I'm sorry I've updated the file before noticing your PR.
Would you wish to resolve the conflicts, or can I push your changes myself? I think it could look something like this:
--- a/src/utils/customdeck.ts
+++ b/src/utils/customdeck.ts
@@ -10,7 +10,7 @@ export class CustomDeck {
deckCards: TFile[];
flip: number[] = [0];
- private supportedExtensions = ["jpg", "jpeg", "png"];
+ private supportedExtensions = ["jpg", "jpeg", "png", "webp", "bmp", "svg"];
constructor(vault: Vault, folder: TFolder) {
this.vault = vault;
@@ -72,9 +72,10 @@ export class CustomDeck {
}
const bytes = await this.vault.readBinary(file);
- const value =
- `data:image/${file.extension.replace("jpg", "jpeg")};base64,` +
- arrayBufferToBase64(bytes);
+ const contentType =
+ "image/" +
+ file.extension.replace("jpg", "jpeg").replace("svg", "svg+xml");
+ const value = `data:${contentType};base64,` + arrayBufferToBase64(bytes);
return {
image: value,
flip: randomFrom(this.flip),
Also, I think there's no need to downcase file.extension
, I've tested different casings and it looks like Obsidian does it by itself when TFile is created.
Sorry, but I haven't tested this, but it should (😅) work. :)
For
.svg
files the mime type isimage/svg+xml
so we need an extra check in there.