This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Allow SVG media images to be uploaded to WordPress
Allowing the uploading of SVG files to the WordPress media library through a simple snippet.
Out of the box, WordPress doesn’t allow the uploading of SVG files for security reasons. SVG images are essentially XML files which themselves are vulnerable to a variety of vulnerabilities. However, if you need to allow the uploading of SVG files to your media library through the WordPress admin, you can do so by adding this simple snippet to your functions.php file or an equivalent.
/*
* Allow SVG images to be uploaded to the media library
*/
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');