Hi i have started converting a lot of my sites old image to SVG format and i cannot get them to display in the page.
The images do load if I open the image seperatly and then view the page after opening it. The SVG's are in the correct file path that I am referencing but nothing appears. Although on some refreshes it does appear.
<img class="padlock-img" src="content/img/cf/padlock.svg" alt="">
<img src="content/img/tips/progress.svg" alt="">
<img class="padlock-img" src="content/img/cf/padlock.svg" alt="">
Example of one of the SVG's
I have attemted turning src into xlink:href
and this stopped the images from loading at all
I have tested this on 3 other browsers and the images load it is only happening on chrome on localhost and on file://
Any ideas on how to fix this?
Chrome browser doesn't support SVG format with <img src=””> tag anymore. Peoples are facing issues that they aren't able to see their images in Chrome browser because the images are in SVG format. So I found a solution to display SVG image in Chrome browser with <object> tag.
If you are trying to use SVG like <img src="image. svg"> or as a CSS background-image , and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type.
SVG (basic support) is Fully Supported on Google Chrome 94. If you use SVG (basic support) on your website or web app, you can double-check that by testing your website's URL on Google Chrome 94 with LambdaTest. The features should work fine.
SVG (Scalable Vector Graphics) is officially supported by all main web browsers, including Internet Explorer.
When using SVG in Chrome, you need to make sure that your root tag has xmlns="http://www.w3.org/2000/svg"
I haven't been able to find the problem, but one alternative would be
<object data="yours.svg" type="image/svg+xml"></object>
this seems to do the trick for all browsers.
For what it's worth I had an image like this
<img src="public/image/circles/circle.svg" class="circle_img" />
If you open the svg in an editor I changed
xlink:href="data:img/png;base64
to xlink:href="data:image/png;base64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With