Last active
August 29, 2015 14:18
-
-
Save schlessera/1eed8503110fb3076e73 to your computer and use it in GitHub Desktop.
Enable SVG file upload through WordPress Media Uploader
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 | |
/** | |
* Add the SVG Mime type to the uploader | |
* @author Alain Schlesser ([email protected]) | |
* | |
* @param array $mimes list of mime types that are allowed by the | |
* WordPress uploader | |
* @return array modified version of the $mimes array | |
* | |
* @see https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes | |
* @see http://www.w3.org/TR/SVG/mimereg.html | |
*/ | |
function as_svg_mime_type( $mimes ) { | |
// add official SVG mime type definition to the array of allowed mime types | |
$mimes['svg'] = 'image/svg+xml'; | |
// return the modified array | |
return $mimes; | |
} | |
add_filter( 'upload_mimes', 'as_svg_mime_type' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment