How to add SVG images to WordPress Library

by | Quick Divi Tips | 1 comment

Uploading SVG images to WordPress

WordPress by default doesn’t let us upload svg files. We can easily change this behaviour with a simple function in the functions.php file. This is the code:

// Allow SVG uploads

function allow_svgimg_types($mimes) {
  $mimes['svg'] = 'image/svg+xml';
  return $mimes;
}
add_filter('upload_mimes', 'allow_svgimg_types');

Just copy and paste it anywhere before the ending tag ?> in your theme functions.php file. And that’s it – now you can choose files with SVG format when you aploading them in WordPress. You won’t see the preview image though. So it’s important to name the files accordingly before upload, so you’ll know which one is which.

 

Remember to use Child Theme

If you using Divi or any other pre-made theme – don’t forget to make a child theme first, and make the changes in functions.php file in your child theme. If you make changes in the parent themes files – then all your changes will be gone if you update the theme.

Have you seen our Divi Child Themes?

We offer a great selection of high-quality designs to speed up your work. Feel free to use a coupon code IREADBLOG at the checkout to get a 10% discount!

1 Comment

Trackbacks/Pingbacks

  1. WordPress: SVG Dateien in die Mediathek hochladen - […] Freie Übersetzung des Blogartikels „Uploading SVG images to WordPress“ von der Webseite […]

Submit a Comment

Your email address will not be published. Required fields are marked *

Shares

Pin It on Pinterest