mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Add CORS support to ImageTileSource
This commit is contained in:
parent
9a4543cd73
commit
3316a55b97
@ -46,6 +46,7 @@
|
||||
*/
|
||||
$.ImageTileSource = function (options) {
|
||||
|
||||
this.options = options;
|
||||
$.TileSource.apply(this, [options]);
|
||||
|
||||
};
|
||||
@ -64,13 +65,13 @@
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {Image} image - the actual image
|
||||
* @param {Object} options - the options
|
||||
* @param {String} dataUrl - the url the image was retreived from, if any.
|
||||
* @return {Object} options - A dictionary of keyword arguments sufficient
|
||||
* to configure this tile sources constructor.
|
||||
*/
|
||||
configure: function (image, dataUrl) {
|
||||
return image;
|
||||
configure: function (options, dataUrl) {
|
||||
return options;
|
||||
},
|
||||
/**
|
||||
* Responsible for retrieving, and caching the
|
||||
@ -83,6 +84,13 @@
|
||||
var image = new Image();
|
||||
var _this = this;
|
||||
|
||||
if (this.options.crossOriginPolicy) {
|
||||
image.crossOriginPolicy = this.options.crossOriginPolicy;
|
||||
}
|
||||
if (this.options.ajaxWithCredentials) {
|
||||
image.useCredentials = this.options.ajaxWithCredentials;
|
||||
}
|
||||
|
||||
image.addEventListener('load', function () {
|
||||
_this.width = image.naturalWidth;
|
||||
_this.height = image.naturalHeight;
|
||||
|
@ -2045,6 +2045,7 @@ function getTileSourceImplementation( viewer, tileSource, successCallback,
|
||||
//If its still a string it means it must be a url at this point
|
||||
tileSource = new $.TileSource({
|
||||
url: tileSource,
|
||||
crossOriginPolicy: viewer.crossOriginPolicy,
|
||||
ajaxWithCredentials: viewer.ajaxWithCredentials,
|
||||
success: function( event ) {
|
||||
successCallback( event.tileSource );
|
||||
@ -2054,7 +2055,10 @@ function getTileSourceImplementation( viewer, tileSource, successCallback,
|
||||
failCallback( event );
|
||||
} );
|
||||
|
||||
} else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ) {
|
||||
} else if ($.isPlainObject(tileSource) || tileSource.nodeType) {
|
||||
if (!tileSource.crossOriginPolicy && viewer.crossOriginPolicy) {
|
||||
tileSource.crossOriginPolicy = viewer.crossOriginPolicy;
|
||||
}
|
||||
if (tileSource.ajaxWithCredentials === undefined) {
|
||||
tileSource.ajaxWithCredentials = viewer.ajaxWithCredentials;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user