I am interested in
adding svg files to wordpress website
August 7, 2019
August 7, 2019

How to Add SVG in WordPress

In this tutorial, we are going to edit functions.php file. Don’t know where to find this file? No worries, we have an entire article where we teach you where to find it. Also, you can watch a video tutorial on our channel.

SVG format got widely popular especially after the introduction of Retina Displays, because it never gets pixelated and always maintains the best quality. But once you try to upload such file in your WordPress website, you will get an error message. Fortunately, there is a short snippet code that you just need to enter to your functions.php file. Then you will immediately will be able to upload SVF files to your Media Library.

function add_file_types_to_uploads($file_types){

    $new_filetypes = array();
    $new_filetypes['svg'] = 'image/svg+xml';
    $file_types = array_merge($file_types, $new_filetypes );

    return $file_types;
add_action('upload_mimes', 'add_file_types_to_uploads');

And that’s really it. Short but powerful code 🙂

Sign up to our newsletter