0

I was retrieving an image from parse using a url, like this

var imgPaht = user.get("ProfilePic");

    $('<img src="' + imgPaht + '">').load(function() {
        $(this).width(400).height(400).appendTo('#profile_pic');
    })

Now in parse, the image is not held as a string, its held as a file. How do I change the above line to work with a file and not a url.

I've tried

var profilePhoto = profile.get("ProfilePic");
$("profileImg")[0].src = profilePhoto.url();

Parse backend
Error I'm getting enter image description here

Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
Dano007
  • 1,872
  • 6
  • 29
  • 63
  • This is probably answered here: http://stackoverflow.com/questions/20035615/using-raw-image-data-from-ajax-request-for-data-uri but does not use/require jQuery, just plain JS. – Joey T Oct 30 '14 at 18:06
  • when you say "file" is it Base64 as in answer? or other? –  Oct 30 '14 at 18:31
  • @RokoC.Buljan I've checked, it certainly is a object... – Dano007 Oct 30 '14 at 20:17

1 Answers1

0

Encoded image file data will not insert directly into an img tags src property. It must be decoded first into raw image data and then assigned to the src property prefixed with data:.

See Using raw image data from ajax request for data URI for more information on how to do this.

Community
  • 1
  • 1
Joey T
  • 774
  • 7
  • 11