fix: set crossOrigin on images for sandbox canvas export
CDN already serves Access-Control-Allow-Origin: * but browsers only send the Origin header when img.crossOrigin is set. sandbox.js now sets crossOrigin="anonymous" on all images at init and after SPA navigation so canvas.toBlob() can read pixels for export.
This commit is contained in:
parent
9dda6ca36b
commit
64a71f0bb2
1 changed files with 14 additions and 0 deletions
|
|
@ -101,10 +101,23 @@
|
|||
buildSliders();
|
||||
buildActions();
|
||||
buildFaceSection();
|
||||
enableCrossOrigin();
|
||||
restoreState();
|
||||
setupEvents();
|
||||
}
|
||||
|
||||
// Set crossOrigin on all images so canvas export can read pixels.
|
||||
// The CDN already serves Access-Control-Allow-Origin: * but the
|
||||
// browser only sends the Origin header when crossOrigin is set.
|
||||
function enableCrossOrigin() {
|
||||
var imgs = document.querySelectorAll('img');
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
if (!imgs[i].crossOrigin) {
|
||||
imgs[i].crossOrigin = 'anonymous';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetSliderValues() {
|
||||
for (var i = 0; i < SLIDERS.length; i++) {
|
||||
sliderValues[SLIDERS[i].id] = SLIDERS[i].dflt;
|
||||
|
|
@ -275,6 +288,7 @@
|
|||
window.sandboxReapply = function() {
|
||||
// Small delay to let new DOM settle
|
||||
setTimeout(function() {
|
||||
enableCrossOrigin();
|
||||
applyCurrentFilter();
|
||||
}, 50);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue