Change missing cacheKey in Tilesource constructor to warning. Provide default implementation of getTileHashKey for tileSource if the tileSource does not inherit from OpenSeadragon.TileSource

This commit is contained in:
Aiosa 2022-08-09 10:40:57 +01:00
parent 12402f2f0f
commit 298f069c7e
2 changed files with 6 additions and 1 deletions

View File

@ -129,7 +129,7 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
this.ajaxHeaders = ajaxHeaders;
if (cacheKey === undefined) {
$.console.error("Tile constructor needs 'cacheKey' variable: creation tile cache" +
$.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache" +
" in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used.");
cacheKey = $.TileSource.prototype.getTileHashKey(level, x, y, url, ajaxHeaders, postData);
}

View File

@ -1398,6 +1398,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
options.ajaxHeaders = $.extend({}, this.ajaxHeaders, options.ajaxHeaders);
}
if (!$.isFunction(options.tileSource.getTileHashKey)) {
//silently add custom implementation
options.tileSource.getTileHashKey = $.TileSource.prototype.getTileHashKey;
}
var myQueueItem = {
options: options
};