I have a function that can output base64 encode encoded image data to a tag. The following works:
echo '<img src="'.$base64.'">';
But if I try the following with same prepared data, it no longer works.
echo '<body background="'.$base64.'">';
Any solutions for this to work in tag directly?
EDIT: I wish to note that I was unable to manipulate the background attributes via Javascript after using the following method in the accepted solution:
echo '<body style="background: url(data:image/png;base64,'.$base64.')">';
However I fixed this by echoing the image-data with php directly to the style instead inside style tags:
<style>
body {
<?php
echo 'background-image: url('.$base64.');' . "\n";
echo 'background-size: 100% 100%;' . "\n";
?>
}
</style>
I am not sure why is behaves differently.