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