XML version tag causing errors on output
-
Hi there
Fantastic plugin, but I’m having issues when outputting an uploaded SVG file. I use the following code to render it as an inline SVG:
include get_attached_file($file_ID);
The error I get is:
“Parse error: syntax error, unexpected identifier “version” in?/<filepath and name>.svg?on line?1“
The issue seems to be the XML version tag, which gets added when I upload the SVG.
<?xml version="1.0" encoding="UTF-8"?>
When I remove that line from the file in the /uploads/ folder, the error goes away and the image is rendered correctly.
This happens with PHP 7.3, 8.1 and 8.2, and also WordPress 6.2.
It’s not there when I upload it; the plugin adds it. And I need to include it as an inline SVG so that it can be styled dynamically with CSS.
Any way around this? Can I stop the xml tag being added somehow? Or is there a better way for me to render the file on the PHP page? Manually editing an uploaded file via FTP isn’t really feasible for me to ask a client to do.
Thanks in advance.
Ben
- The topic ‘XML version tag causing errors on output’ is closed to new replies.