SVG Upload on WordPress Site

SVG Upload on WordPress Site

This requires 2 pierces of code
1- In wp-config.php

define( 'ALLOW_UNFILTERED_UPLOADS', true );

2- Add following code in functions.php

function upload_svg_files( $allowed ) {
    if ( !current_user_can( 'manage_options' ) )
        return $allowed;
    $allowed['svg'] = 'image/svg+xml';
    return $allowed;
}
add_filter( 'upload_mimes', 'upload_svg_files');

Leave a Reply

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