Upload SVG Files To WordPress

Allowing SVG Files in WordPress so you can upload them through the Media panel is surprisingly simple. This allows you to harness the power and speed benefits of SVG Files as opposed to Raster Images.

Either add the following snippet to your theme's functions.php file or create a WordPress plugin that executes the following code:

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

There are security concerns to allowing SVG files to be uploaded, so make sure that only trusted contributors have access to uploading.