Search code examples
htmlazuresvgazure-blob-storageazure-cdn

Why are SVG images not displaying when linked from blob storage?


I have a blazor WASM site, and I am trying to display an SVG image directly from blob storage. I have tried using

<img src="https://rmssdstorage.blob.core.windows.net/mixandswirlimages/cbf53722-5889-4100-8c2e-30b8500e1a3d.svg" height="300"/>

but this results in a broken image link. You can see that this image is there on the server: you are able to download it by clicking on the link: https://rmssdstorage.blob.core.windows.net/mixandswirlimages/cbf53722-5889-4100-8c2e-30b8500e1a3d.svg

I've also tried using

<object type="image/svg+xml" src="https://rmssdstorage.blob.core.windows.net/mixandswirlimages/cbf53722-5889-4100-8c2e-30b8500e1a3d.svg"></object>

but this seems to cause the image to download to your device (but will still not cause it to be displayed on the page).

If I link to an image from another source, it DOES display:

<img src="https://upload.wikimedia.org/wikipedia/commons/8/8c/Aperiodisk-v%C3%A4xelstorhet.svg" height="300" />

Why is it that I can display images from other sites, but cannot display them from my Azure CDN Blob Storage, even though these images are publicly accessible?


Solution

  • I suspect that you might need to set the content-type of the blob. By default it is application/octet-stream. See https://stackoverflow.com/a/50103396/2170938