Encoded string to an image RRS feed

  • Question

  • Hi all,

    I have a image library which can access using  


    http://myurl/imageban/25    etc  . 

    and that returns base64 encoded image string, and i wanted to load this in to  <img  src=" />     etc. 

    could some one please let me know how do we do this using java script ? 


    Wednesday, January 28, 2015 3:32 PM


  • If you already know how to access the image element and how to download the string using JavaScript or JQuery, then, according to “data” protocol (https://msdn.microsoft.com/en-us/library/cc848897(v=vs.85).aspx), assign a special value to src attribute, for example:

        myImageElement.src = "data:image/png;base64," + downloadedString;

    Also consider returning the binary image directly instead of a longer string (if the library is made by you). In this case you will just have:

        myImageElement.src = "http://myurl/imagebank/" + imageNumber;

    • Edited by Viorel_MVP Thursday, January 29, 2015 7:08 AM
    • Marked as answer by CaillenModerator Wednesday, February 4, 2015 10:03 AM
    Thursday, January 29, 2015 7:05 AM