add crossOriginPolicy drawer configuration to enable or disable CORS image requests

This commit is contained in:
Chris Beer 2014-03-20 10:30:46 -07:00
parent 1643660f17
commit 3d028716fe
3 changed files with 13 additions and 3 deletions

View File

@ -100,7 +100,8 @@ $.Drawer = function( options ) {
alwaysBlend: $.DEFAULT_SETTINGS.alwaysBlend, alwaysBlend: $.DEFAULT_SETTINGS.alwaysBlend,
minPixelRatio: $.DEFAULT_SETTINGS.minPixelRatio, minPixelRatio: $.DEFAULT_SETTINGS.minPixelRatio,
debugMode: $.DEFAULT_SETTINGS.debugMode, debugMode: $.DEFAULT_SETTINGS.debugMode,
timeout: $.DEFAULT_SETTINGS.timeout timeout: $.DEFAULT_SETTINGS.timeout,
crossOriginPolicy: $.DEFAULT_SETTINGS.crossOriginPolicy
}, options ); }, options );
@ -303,7 +304,10 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
this.downloading++; this.downloading++;
image = new Image(); image = new Image();
image.crossOrigin = 'Anonymous';
if (_this.crossOriginPolicy !== false) {
image.crossOrigin = _this.crossOriginPolicy;
}
complete = function( imagesrc, resultingImage ){ complete = function( imagesrc, resultingImage ){
_this.downloading--; _this.downloading--;

View File

@ -403,6 +403,10 @@
* *
* @property {Number} [collectionTileSize=800] * @property {Number} [collectionTileSize=800]
* *
* @property {String} [crossOriginPolicy='Anonymous']
* Valid values are 'Anonymous', 'use-credentials', and false. If false, canvas requests will
* not use CORS, and the canvas will be tainted.
*
*/ */
/** /**
@ -717,6 +721,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
tileSources: null, tileSources: null,
tileHost: null, tileHost: null,
initialPage: 0, initialPage: 0,
crossOriginPolicy: 'Anonymous',
//PAN AND ZOOM SETTINGS AND CONSTRAINTS //PAN AND ZOOM SETTINGS AND CONSTRAINTS
panHorizontal: true, panHorizontal: true,

View File

@ -1662,7 +1662,8 @@ function openTileSource( viewer, source ) {
minPixelRatio: _this.collectionMode ? 0 : _this.minPixelRatio, minPixelRatio: _this.collectionMode ? 0 : _this.minPixelRatio,
timeout: _this.timeout, timeout: _this.timeout,
debugMode: _this.debugMode, debugMode: _this.debugMode,
debugGridColor: _this.debugGridColor debugGridColor: _this.debugGridColor,
crossOriginPolicy: _this.crossOriginPolicy
}); });
// Now that we have a drawer, see if it supports rotate. If not we need to remove the rotate buttons // Now that we have a drawer, see if it supports rotate. If not we need to remove the rotate buttons