The WordPress core developers have been discussing the right way to handle SVG files for years – the background is security concerns, as it’s a file format that could allow authors to inject malicious code into WordPress through media uploading – and not just admins.

Therefore, WordPress does not allow SVG files to be uploaded to WordPress. For years, we have been using the plugin SVG Support, which we have already financially supported.

But since version 5 of WordPress, the SVG files must contain an extra line of code to be uploaded:

<?xml version="1.0" encoding="utf-8"?>

Insert this line at the beginning of your SVG file with a text editor and together with the above mentioned. With the plugin mentioned above, SVG upload should work then without further errors.

Keep in mind that cropping the image in WordPress will not work as SVGs will not, so if you’re asked to upload it, just skip this feature.

You have not worked with text files yet? Here’s how to edit plain text files.