How To Add SVG Upload Support To WordPress

By default, WordPress wouldn’t let you upload SVG files through the media uploader. However, a little piece of code will solve this problem for you. Just add following code to your theme’s functions.php file:

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

Above snippet would work like a charm. However, it displays huge wherever it gets displayed in WordPress Admin, so add following code to your function.php to fix this problem:

function fix_svg() {
   echo '<style type="text/css">
         .attachment-266x266, .thumbnail img { 
              width: 100% !important; 
              height: auto !important; 
         }
         </style>';
}
add_action('admin_head', 'fix_svg');