Display Base 64 Image
Display Base 64 Image
Hi!
I have a base64 string image in my databse, How can I display this image in a row?
Example:
String: iVBORw0KGgoAAAANSUhEUgAAAEAAAA......
<img src="data:image/png;base64,iVBORw0KGgoAAAAN" />
What I want is to get the string and add the html img tag to display the image correctly.
I hope I made my self clear.
Thank you.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
More than one? I usually create a css class that contains that image then add the class to a span or button whatever depending on context of how its being used.
I built one that puts check marks on buttons inside a datatable. You can see it
http://jsbin.com/dibuga/edit?html,css,js,output
@alf007 - We'd really need more information. Are you ajax loading the data and that contains the base 64 string for example? In which case use a renderer to create the img tag.
Allan
Thanks @allan, @bindrid for your comments. I finally solve the problem using a renderer.
Here is the result:
image: 'data:image/png;base64,<?php $im = file_get_contents('images/reportheader.png'); $imdata = base64_encode($im); echo $imdata; ?>'