cliffordp
12/23/2015 - 8:18 AM

Make SVG preview images appear in Media Library and give them visual distinction so you know they're SVG files -- e.g. darkred border and ba

Make SVG preview images appear in Media Library and give them visual distinction so you know they're SVG files -- e.g. darkred border and background (also helps identify transparency within SVG file)

<?php
// source: https://gist.github.com/cliffordp/49c824f80debb07c9894
// Make SVG preview images appear in Media Library
// And give them visual distinction so you know they're SVG files -- e.g. darkred border and background (also helps identify transparency within SVG file)
add_action( 'admin_head', 'tk_preview_svgs_in_media_library' );
function tk_preview_svgs_in_media_library() {
  echo '<style>
    svg,
    img[src$=".svg"] {
      width: 100%;
      max-height: 100%;
      border-color: darkred;
      background-color: rgba( 139, 0, 0, .05 ); /* darkred as rgba */
    }
  </style>';
}