I have a base64 image that i need to display via php. It's to be used on a wordperss/woocommerce site, at the cart.
The string is correct and working fine when inserting directly into plain html img tag. The string starts as such: data:image/png;base64...............
But when it's inserted as src, via php, it doesn't include the beginning "data:" word. It displays as: image/png;base64...............
I have tested the string with plain echo, and it does include data: when just echoed out, but as soon as it's palced inside src or href, data: goes away.
I have no idea why this is happening and search results in no meaningful information.
Added code snippet:
$img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAImCAYAAACrXu7BAAAgAE................";
echo '<img src="'.$img.''" />';
data: disappears, echoes out as:
<img src="image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAImCAYAAACrXu7BAAAgAE................" />
But if i do this:
$img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAImCAYAAACrXu7BAAAgAE................"
echo $img;
It works and echoes as:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAImCAYAAACrXu7BAAAgAE................