This is based off a past question of mine, but its a different question and I think making a new question will help many people who have this problem also.
Here is what I have
<img src="data:image/png;base64,<?php echo picture(); ?>" />
The image shows up as a broken image, and when inspect it as an element it shows up as the correct thing.... but with some weird tags at the end
{base64 data}<html>
<head>
<title>Test</title>
</head>
<body>
<img src=" data:image="" png;base64,<html="">
Does anyone know why this is? Its so bizarre.
Thanks!
Edit: So the title of the page is "Test"... but i dont get why its all showing up in the image tag
As noted by Dagon use of data:image is bad idea as you then depend on browser's implementation (which is out of your control and often it is broken).
I suggest you to use link to php script
<html>
<head>
<title>Test</title>
</head>
<body>
<img src="getpicture.php" />
</body></html>
getpicture.php:
<?php
function getPicture()
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'image url');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer XXXX'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$picture = curl_exec($ch);
curl_close($ch);
return $picture;
}
header("Expires: " . date("D, j M Y H:i:s", strtotime("+1 year")));
header("Content-Type: image/png");
echo getPicture();
?>