Reputation: 1
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................
Upvotes: 0
Views: 125
Reputation: 1
I found the issue.
It was indeed wordpress/woocommerce that was the issue, specifically in the cart and not syntax errors...
The issue is do to: wp_filter_post_kses
I will mark this as resolved...
Thanks to those who actually tried to help and understand that the code snippet was not the real code and that there was no syntax errors, as i stated.
Maybe people should not be overly pedantic when trying to help? Just a thought...
Upvotes: 0