Use Base64 String from URL in src tag of image

Viewed 42331

I have an service which returns the base64 version of an image. Now i want to use the base64 string in the src tag of an img. The service offers the base64 version under http://localhost:8080/file/301/base64.

The base64 string looks like this:

data:image/gif;base64,iVBORw0KGgo ...

My img tag on the page currently looks like this:

<img alt="" src="http://localhost:8080/file/301/base64" style="height:836px; width:592px">

Is there any way to get this running?

3 Answers

For base64 encoded .png and .jpg images, to remove single quotes use utf-8 while encoding.

Example:

src="data:image/jpeg;base64,iVBORw0KG...."
Related