0

I am trying to reference/insert a dynamically uploaded svg file (image) from a products database using PHP. So far uploading the images work fine, as I can use them with an image tag and they show up fine.

<img src="image.svg" />

The XML also shows up correctly when I open them on my computer (using a text editor for example).

The problem is I can't seem to get them to be displayed inline so I can use styles like fill.

Here is my PHP code that dynamically displays the image:

<svg id="svg-image" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
   <image id="main-image" xlink:href="<?php echo tep_href_link('images/' . $product_info['products_image']); ?>" />
</svg>

I tried changing image to path in the above code to get it to work, and the image just disappears on reload. Any help is greatly appreciated.

RodeoRamsey
  • 498
  • 2
  • 8
  • 20
  • The problem is not the PHP. Please take a look at this question: [img src SVG changing the fill color](https://stackoverflow.com/questions/24933430/img-src-svg-changing-the-fill-color): 15 Answers – enxaneta Mar 18 '19 at 07:51
  • Yes I know about img src not allowing the fill color code, which is why I am trying to change my PHP code to spit out the correct SVG code. I'm just not sure what I'm missing. – RodeoRamsey Mar 18 '19 at 14:53
  • Just include the .svg file, without any wrapper. As long as you can set width and height in a stylesheet, it should just work. – ccprog Mar 18 '19 at 17:38
  • And how do I "just include the svg file"? This is a dynamically created page from PHP. That's what I'm not clear on in the first place - how to programatically include the file. – RodeoRamsey Mar 18 '19 at 20:08

0 Answers0