kennethcachia / background-check

Automatically switch to a darker or a lighter version of an element depending on the brightness of images behind it.
http://kennethcachia.com/background-check/
MIT License
3.27k stars 282 forks source link

cross-origin errors #28

Open OfficeBureau opened 10 years ago

OfficeBureau commented 10 years ago

Background-check fails not-so-gracefully if image elements don't share the same origin domain.

Modifying line 43:

attrs.images        = getElements(a.images || 'img', true);

to:

attrs.images        = getElements(a.images || 'img[src^="'+window.location.protocol+'//'+window.location.hostname+'"]', true);

prevents this issue when no image selector is provided, but it's still possible for a user to provide a selector that includes cross origin images.

webmatrixxxl commented 9 years ago

Just download background-check and in slider example I get:

Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.

The above doesn't fix it.

homerjam commented 9 years ago

60 might help you @webmatrixxxl