Qobuz: test if max size image exists before replacing link

Replacing _600 with _max doesn't always work, sometimes the _max image isn't
available.
So only replace the link if it makes sense.
This commit is contained in:
Laurent Monin 2015-07-24 10:13:55 +02:00
parent 125afdd651
commit ff20cd7db7

View file

@ -158,6 +158,15 @@ $(document).ready(function() {
});
// replace image zoom link by the maximum size image link
$("#product-cover-link").attr("href", $("#product-cover-link").attr("href").replace('_600', '_max'));
$("#product-cover-link").attr("title", $("#product-cover-link").attr("title") + ' (Qobuz importer: hires image)');
var maximgurl = $("#product-cover-link").attr("href").replace('_600', '_max');
var maximg = new Image();
maximg.onerror = function (evt) {
LOGGER.debug("No max image");
}
maximg.onload = function (evt) {
$("#product-cover-link").attr("href", maximgurl);
$("#product-cover-link").attr("title", $("#product-cover-link").attr("title") + ' (Qobuz importer: ' + maximg.width + 'x' + maximg.height + ' image)');
}
maximg.src = maximgurl;
});