Vannkorn

Full Stack Web Developer

Close

Force WordPress to accept SVG upload without a plugin

Before I come to this trick, I've been using the SVG Support for quite a while.

Ads: Register now via this link to receive $300 credit from Vultr

Before I come to this trick, I’ve been using the SVG Support for quite a while. But for now, only a bunch of code, I can have my WordPress website supports the SVG file type upload like a charm.

function allow_svg_upload($mimes = array()){
    $mimes['svg'] = 'image/svg+xml';
    $mimes['svgz'] = 'image/svg+xml';
    $mimes['json'] = 'application/json';
    return $mimes;
}
add_filter('upload_mimes', 'allow_svg_upload');

Leave a Reply

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