To create data uri in php, read image (png, gif, jpg) file with file_get_contents and convert it to base64 using base64_encode. Using Data URIs you can reduce network requests. But, Please keep in mind if you plan on using data URIs, they are not supported by ie7 and lower.
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/
function createDataURI($image,$mime='') {
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->buffer(file_get_contents($image));
return 'data:'.$mime.';base64,'.base64_encode(file_get_contents($image));
}
?>
How to create data uri
<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.com/ */ echo ''; ?>

';
?>






0 comments:
Post a Comment