2
votes

Is there a way to upload SVG images in the Image block on the Gutenberg editor of WordPress.

I've tried using a plugin called SVG Support but it is still allowing me to upload the image.

It gives the following error:

Sorry, this file type is not permitted for security reasons.

3

3 Answers

2
votes

Add SVG support in your theme or plugin via following code snippet

/**
 * Allow SVG MIME Type in Media Upload
 *
 * @param array $mimes Mime types keyed by the file extension regex corresponding to those types.
*/
function cc_mime_types( $mimes ) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );

For avoiding any security risk you can use this plugin (Safe SVG).

1
votes

You just need an <xml> tag. See the note at the top of https://wordpress.org/plugins/svg-support/

0
votes

Open your svg file and put this code in top of codes.

<?xml version="1.0" encoding="iso-8859-1"?>