Snippets

Function to create data uri’s

These can be useful for embedding images into HTML/CSS/JS to save on HTTP requests.

function data_uri($file, $mime) {
  $contents=file_get_contents($file);
  $base64=base64_encode($contents);
  echo "data:$mime;base64,$base64";
}

Source: http://css-tricks.com/snippets/php/create-data-uris/?utm_sou...

Share this snippet

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!