How to Add Additional File Types to be Uploaded in WordPress458

How-to-Add-Additional-File-Types-to-be-Uploaded-in-WordPress
Author: InfoBeep - December 7, 2017 | subject to copyright

If you have been using WordPress quite for a long, then you may be aware about the fact that you have limitation in uploading file types. For eg: you can most commonly upload image formats, audio/video and documents. But, if you want to upload other file type like “.svg” you have restrictions to do that. In this article, we will guide you to upload other file extensions in WordPress which are not allowed by default.

Procedure

First of all, you need to paste the code below in functions.php file.

functionmy_myme_types($mime_types){

    $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension

    return$mime_types;

}

add_filter('upload_mimes', 'my_myme_types', 1, 1);

Note: This code allows you to add “.svg” files.

If you want to allow multiple file types you need to add the code below:

functionmy_myme_types($mime_types){

    $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension

    $mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files

    return$mime_types;

}

add_filter('upload_mimes', 'my_myme_types', 1, 1);

Note: this code allows you to upload “.svg” code as well as “.psd” files.