I want to trigger a new function once this function returns a callback. That is displayed here:Create a custom callback in JavaScript How do I do that?
function loadImg (imgSrc, callback) {
var newImg = new Image();
newImg.onload = function() {
var height = newImg.height;
var width = newImg.width;
if(height > width){
console.log(false);
if(callback) callback(false);
} else {
console.log(true);
if(callback) callback(true);
}
}
newImg.onerror = function () {
if(callback) callback('error');
}
newImg.src = imgSrc;
}