Skip to content

Instantly share code, notes, and snippets.

@noudadrichem
Created April 28, 2018 07:52
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 noudadrichem/ba8bacfe89bfc38a4fb4e436ac892403 to your computer and use it in GitHub Desktop.
Save noudadrichem/ba8bacfe89bfc38a4fb4e436ac892403 to your computer and use it in GitHub Desktop.
allows SVG mime types in Wordpress, put this snippet in your themes `functions.php` and you're done.
<?php
# mime = meme
function cc_mime_types($memes) {
$memes['svg'] = 'image/svg+xml';
return $memes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg() {
echo '<style media="screen">
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment