Skip to content
Discussion options

You must be logged in to vote

Unfortunately, I don’t think file.image() can work with an SVG image within a ZIP file because the MIME type of the data isn’t known, so the browser can’t infer that you’re trying to display an SVG image.

The file.image() method is implemented using file.url() which calls file.blob(), and the Blob that is constructed by JSZip doesn’t specify a MIME type (because JSZip doesn’t know that _tbd.svg is an SVG file and it doesn’t have an internal database mapping file extensions to MIME types). And so the browser doesn’t know how to display the resulting image.

You can workaround this by constructing the Blob yourself with the appropriate image/svg+xml MIME type:

const logos = await FileAttachment

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by llimllib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants