Wordprerss | Upload SVG or other files in Media Library

| By Webner

In WordPress, by default svg type of files are not permitted to upload.


So in order to upload the SVG files to WordPress media library, we will need to add following code to child theme’s functions.php file:

//To allow svg files uploading 

function allow_svg_upload_mimes($mimes = array()) {

// Add a key and value for the SVG file type

$mimes['svg'] = "text/svg";

return $mimes;


add_action('upload_mimes', 'allow_svg_upload_mimes');

Now, this code will allow the SVG file types to get uploaded to a media library.


Leave a Reply

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