The following code is used to set the attributes of an img and then do something upon img load.
This works fine in Chrome and FireFox, however the let img..etc line never gets hit in Safari. Why is this?
$("<img/>").attr("src", "data:image/*; base64," + base64).on("load", (e) => {
let img = e.currentTarget;
context.scale(width / img.width, height / img.height);
context.drawImage(img, 0, 0);
deferred.resolve($("<img/>").attr("src", canvas.toDataURL()));
});
I've tried with the tech preview version of safari, to no avail. This occurs on Mac and iPhone.
Edit:
As per Cross-browser image onload event handling
I've tried, to no avail:
var image = $('<img/>');
image.on('load', e => {
let img = e.currentTarget;
context.scale(width / img.width, height / img.height);
context.drawImage(img, 0, 0);
deferred.resolve($('<img/>').attr('src', canvas.toDataURL()));
});
image.attr('src', 'data:image/*; base64,' + base64);
I've also tried with plain javascript
var image = $('<img/>');
image.onload = function(e) {
let img = e.currentTarget;
context.scale(width / img.width, height / img.height);
context.drawImage(img, 0, 0);
deferred.resolve($('<img/>').attr('src', canvas.toDataURL()));
};
image.src = "data:image/*; base64," + base64;