Skip to content

Instantly share code, notes, and snippets.

@mikesprague
Last active April 19, 2016 02:14
Show Gist options
  • Save mikesprague/91c048a8ee1939f388eaeb3e82d58293 to your computer and use it in GitHub Desktop.
Save mikesprague/91c048a8ee1939f388eaeb3e82d58293 to your computer and use it in GitHub Desktop.
Create and output data URI from an image file
<?php
function create_data_uri( $file, $mime ) {
$contents=file_get_contents( $file );
$base64=base64_encode( $contents );
echo "data:$mime;base64,$base64";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment