SVG images are great to use for your logo because of their scalability. However, by default you can’t upload SVG images to your Divi website. In this tutorial, I’ll show you 2 methods on how you can do this.
SVG Support plugin
The first method is with the SVG Support plugin by Benbodhi. After installing and activating this plugin you are able to upload SVG images. If you go to Settings > SVG Support than you find under settings some additional options.
If you check “Restrict to Administrators” than this will allow that only administrators can upload SVG images.
When you check the option “Enable Advanced Mode” you will get more advanced options for this plugin.
Manual method for uploading SVG logo to your Divi theme
In case you don’t want to use an extra plugin then you can also do this by adding some PHP code to your functions.php file. I strongly recommend doing this in your child theme functions.php file, if you are not doing this than your changes will be lost after a WordPress update. You can learn here how to create a child theme for Divi.
Place the following code in your child theme functions.php file:
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
You have now 2 methods on how you can upload an SVG logo to your Divi theme.
Where is the code snippet? The line is empty….
The code is back now
Can I remove the code from functions file after uploading? Would this close the vulnerability that developers often discuss about svg?
Hi,
You should be able to remove that code afterward, although I am not 100% sure if the SVG will still work then, but I think it will.
I still can’t add svg to the library with the code (I can’t use the pluggin since it makes my divi pages insecure and I can’t edit them)
Hi Givaro,
Try this plugin: https://wordpress.org/plugins/safe-svg/