nl_tokens: ========================================================================== Load image avoiding xhr / fetch CORS issues Server status can t be obtained this way unfortunately so this uses naturalWidth to determine if the image has loaded By default it checks if it is at least 1px but you can add a second argument to change this ==========================================================================
pl_tokens: function loadImage ( src ) { var minWidth = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 1 ; return new Promise ( function ( resolve , reject ) { var image = new Image ( ) ; var handler = function handler ( ) { <mask> image . onload ; delete image . onerror ; ( image . naturalWidth >= minWidth ? resolve : reject ) ( image ) ; } ; Object . assign ( image , { onload : handler , onerror : handler , src : src } ) ; } ) ; }