Skip to content

Instantly share code, notes, and snippets.

@juliozuppa
Created March 13, 2017 12:40
Show Gist options
  • Save juliozuppa/ef217dd761f6173b37b6929893bd2c1f to your computer and use it in GitHub Desktop.
Save juliozuppa/ef217dd761f6173b37b6929893bd2c1f to your computer and use it in GitHub Desktop.
html imagem base64
<?php
// <img src="data:image/png;base64,...> data:image/jpeg;charset=utf-8;base64,
// http://danielmclaren.com/node/90
$image = 'http://images.itracki.com/2011/06/favicon.png';
// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));
// Format the image SRC: data:{mime};base64,{data};
$src = 'data: '.mime_content_type($image).';base64,'.$imageData;
// Echo out a sample image
echo '<img src="'.$src.'">';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment