Reputation: 55
I'm setting up a project, and I decided that the best alternative was to save the images in Base64 and save it in the database. This is OK, all right. However, when I need to render them on the front end, the following is not working, for some reason, can someone help me?
<img class="whatever" src="<%= datasetresult[1].photo%>">
When I look at the browser console, Base64 is there, so I don't understand why it isn't rendering.
HELP!
EDIT
Upvotes: 3
Views: 1723
Reputation: 7136
The src
tag of images can accept base64 strings, if you specify the type. For example, if you have a jpeg image, you need to prefix the base64 string with data:image/jpeg;base64,
.
If you have SVG (with or without raster data), you need to use data:image/svg+xml;base64,
.
Upvotes: 2