Is there a syntax that will allow me to reference an inline svg by id in an img tag’s src attribute?
Or is it possible to echo the svg code directly into the src attribute?
I’d prefer to avoid creating a duplicate file and a duplicate HTTP request, if possible.
For a previously loaded svg with id = #my_svg"
, I tried:
src="url(#my_svg)"
.
I also tried printing the svg directly into the src attribute from the server, like this:
<img src="data:image/svg+xml;utf8,
<?php
$svg_str = logo_svg();
$svg_str = str_replace('"', "'", $svg_str);
echo $svg_str;
?>
"
style="position:absolute;width:100%;height:100%">
</img>
2
Answers
If you want to avoid this, you can create an assets folder in your GitHub repository and put the svg you want to use, it works well, because some links only work if they are hosted in specific places sometimes, you can create a folder in github with your icons and images, and when you need to use them, you just use the link to your own repository and adjust the size of the icons
}
An example of gradient created in javascript