Last active
June 6, 2022 12:42
-
-
Save paolo-mnet/b588b8d7d9ccf4b1e68a4af8b8c9b3f7 to your computer and use it in GitHub Desktop.
WordPress: Allow upload of non-standard file types in the media library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// functions.php | |
/** | |
* Allow upload of non-standard file types in the media library. | |
* | |
* @param array $mime_types [default mime types]. | |
* @return array $mime_types [modified mime types]. | |
*/ | |
function mnet_upload_mime_types($mime_types) { | |
if ( !isset($mime_types['webp']) ) { | |
$mime_types['webp'] = 'image/webp'; | |
} | |
if ( !isset($mime_types['svg']) && current_user_can('edit_posts') ) { | |
$mime_types['svg'] = 'image/svg+xml'; | |
} | |
return $mime_types; | |
} | |
add_filter('upload_mimes', 'mnet_upload_mime_types', 110, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment