I have SVG files for certain images that need to show in my single page application (build with Laravel and RiotJS). I tried several ways to display it on the page but it only shows a broken image on the web page. Then I extract the SVG code (starts with <svg xmlns="http://www.w3.org/2000/svg" ....) and put it on the database and retrieve it. It works. But I think it's not the best way to do something like that since I have hundreds of SVGs and this approach will overload my database storage quickly. I tried the following ways,
Using img tag
<img src="path/to/mylocal/image.svg" >
Using object tag and embed tag
<object data="path/to/mylocal/image.svg" type="image/svg+xml"></object>
using object and embed tag renders the SVG but leaves a vertical scroll bar.
Edit:- Please note that, I'm getting the string that containing from the database and display it on web page using JQuery like this,
In HTML
<div id="myContainer"></div>
In JQuery
$('#myContainer').html(stringGetFromTheDatabase);
Any kind of help is appreciated. Thanks
You try the below code,
and my.svg should like
it should work.