Skip to content

Instantly share code, notes, and snippets.

@walterebert
Last active December 5, 2016 09:15
Show Gist options
  • Save walterebert/23b52b7d8c19ef8a8f6c to your computer and use it in GitHub Desktop.
Save walterebert/23b52b7d8c19ef8a8f6c to your computer and use it in GitHub Desktop.
WordPress snippet: Allow SVG uploads
<?php
function my_allow_svg( $mimetypes ) {
$mimetypes['svg'] = 'image/svg+xml';
$mimetypes['svgz'] = 'image/svg+xml';
return $mimetypes;
}
add_filter( 'upload_mimes', 'my_allow_svg' );
@walterebert
Copy link
Author

Uploading SVG has some security risks, see: https://bjornjohansen.no/svg-in-wordpress

A better solution is to use the Safe SVG plugin: https://wordpress.org/plugins/safe-svg/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment