Reputation: 63
I'm having trouble setting the background image of a div using a data url. Here's my code, which doesn't throw an error but also doesn't work:
profilePhotoData= shout.get("authorProfPic");
src = 'data:image/png;base64, ' + profilePhotoData.base64
outerDiv.style.backgroundImage="url("+src+")";
Upvotes: 0
Views: 5140
Reputation: 2143
I know this css works:
body {
background: #ffffff url("data:image/jpg;base64,/9j/4...") no-repeat top left;
}
Thus maybe you should:
Upvotes: 2
Reputation: 1418
Remove the line breaks (\r\n) from the base64 string and it should work.
Upvotes: 0