From 298f069c7e046a8b6c735e9fe5e71226a36e107d Mon Sep 17 00:00:00 2001 From: Aiosa Date: Tue, 9 Aug 2022 10:40:57 +0100 Subject: [PATCH] Change missing cacheKey in Tilesource constructor to warning. Provide default implementation of getTileHashKey for tileSource if the tileSource does not inherit from OpenSeadragon.TileSource --- src/tile.js | 2 +- src/viewer.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tile.js b/src/tile.js index b41aa9e9..45f2823b 100644 --- a/src/tile.js +++ b/src/tile.js @@ -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); } diff --git a/src/viewer.js b/src/viewer.js index df553e4c..007f1bf1 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -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 };