Skip to content

Instantly share code, notes, and snippets.

@bradyvercher
Created December 13, 2013 21:56
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 bradyvercher/7952090 to your computer and use it in GitHub Desktop.
Save bradyvercher/7952090 to your computer and use it in GitHub Desktop.
<?php
/**
* Return a base64 encoded SVG icon for use as a data URI.
*
* @param string $path Path to SVG icon.
* @return string
*/
function audiotheme_encode_svg( $path ) {
$path = path_is_absolute( $path ) ? $path : AUDIOTHEME_DIR . $path;
if ( ! file_exists( $path ) || 'svg' != pathinfo( $path, PATHINFO_EXTENSION ) ) {
return '';
}
return 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( $path ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment