How to Allow SVG Through WordPress Media Uploader

Here’s a reusable piece of PHP code which allows the users to upload SVG files via WordPress media uploader. All you have to do is copy the following code and paste it inside the functions.php file located inside your themes directory.

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

Read Also: Restricting Users to View Only their own Media Library Items

Leave a Comment.