Use Php To Prep Svg File For Use In Img Tag Data Uri
I'm using PHP. I would like to use file_get_contents to get an .svg file, and convert it for use as a data uri in an image tag. Something along these lines: Controller: $mylogo   =
Solution 1:
<svg> elements can be echoed directly onto a web page like any other element; there's no need to include it as an imgsrc attribute. PHP's include can be used for this (ie. include('/path/to/image.svg')), amongst a myriad of other methods.
Alternatively, if for some reason you need to include the svg as an actual img tag, there's no need for file_get_contents or similar functions; an SVG can be linked as a source path like any other image type (ie. <image src="/path/to/image.svg">).
Post a Comment for "Use Php To Prep Svg File For Use In Img Tag Data Uri"