SVG Image or the Scalable Vector Graphics image is a image file format for vector graphics. However, if you try to upload an SVG image to your WordPress website using the media uploader, you will get this error:
yourfile.svg has failed to upload due to an error
Sorry, this file type is not permitted for security reasons.
This is because SVG file is not white listed in the allowed file types that can be uploaded to WordPress via its media uploaded. To fix this issue, add this code to your theme’s functions.php file,
functionagentwp_upload_mimes ( $existing_mimes=array() ) {
$existing_mimes['svg'] = 'mime/type';
return $existing_mimes;
}
Once you add this code to your theme’s functions.php file, you will not get any error while uploading the SVG file. Once uploaded, you can add the SVG image to your post and page using this HTML code:
Don’t forget to replace the src with the source of your own uploaded SVG file.