Skip to content

Commit d407151

Browse files
thisconnectzbjornson
authored andcommitted
adds option arg (for crossOrigin attribute) to loadImage (Automattic#1402)
* adds crossOrigin attribute to loadImage without that using the image later with webgl errors DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The image element contains cross-origin data, and may not be loaded. * Standard Style * support any properties on an HTMLImageElement Automattic#1402 (comment) * loadImage accepts any options now
1 parent 290afdb commit d407151

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

browser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ exports.createImageData = function (array, width, height) {
1818
}
1919
}
2020

21-
exports.loadImage = function (src) {
21+
exports.loadImage = function (src, options) {
2222
return new Promise((resolve, reject) => {
23-
const image = document.createElement('img')
23+
const image = Object.assign(document.createElement('img'), options)
2424

2525
function cleanup () {
2626
image.onload = null

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export function createImageData(width: number, height: number): ImageData
294294
* @param src URL, `data: ` URI or (Node.js only) a local file path or Buffer
295295
* instance.
296296
*/
297-
export function loadImage(src: string|Buffer): Promise<Image>
297+
export function loadImage(src: string|Buffer, options?: any): Promise<Image>
298298

299299
/**
300300
* Registers a font that is not installed as a system font. This must be used

0 commit comments

Comments
 (0)