SVGs and the WordPress Media Gallery



If you do a quick search on Google, it’s easy to figure out how to enable SVG support within the WordPress Media Gallery. Simply add the correct MIME type like so:

function cc_mime_types($mimes) {
  $mimes['svg'] = 'image/svg+xml';
  return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');

However the frustrating part is that the uploaded files don’t show up as thumbnails within the gallery itself. This is a major pain in the neck—especially for clients who need the visual cue for their SVGs. Thankfully Lewis Cowles offers a great solution in the form of a super lightweight plugin.

Not only do you get support for uploading SVG files but the images show as previews in the Media Gallery. All in about 4KB. Awesome.