Skip to content

Instantly share code, notes, and snippets.

@ashokdhaduk
Forked from tanmay27vats/function.php
Created May 28, 2018 04:44
Show Gist options
  • Save ashokdhaduk/ebc9025285d4e60930c70cd9eac913aa to your computer and use it in GitHub Desktop.
Save ashokdhaduk/ebc9025285d4e60930c70cd9eac913aa to your computer and use it in GitHub Desktop.
Enable SVG support in Wordpress. How to upload/enable SVG images on wordpress.
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg_thumb_display() {
echo '<style type="text/css">
td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail {
width: 100% !important;
height: auto !important;
}
</style>
';
}
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