Skip to content

Instantly share code, notes, and snippets.

@DarioBF
Created January 26, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarioBF/675b31f6abe4e92f337f to your computer and use it in GitHub Desktop.
Save DarioBF/675b31f6abe4e92f337f to your computer and use it in GitHub Desktop.
Allow SVG files uploads in WordPress
/**
* Allow uploads for SVG files.
*/
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
/**
* Fix the SVG display in media library for WordPress 4.0+
*/
function fix_svg_thumb_display() {
echo '
td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail {
width: 100% !important;
height: auto !important;
}
';
}
add_action('admin_head', 'fix_svg_thumb_display');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment