mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-11-10 13:14:16 +00:00
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:
parent
125afdd651
commit
ff20cd7db7
1 changed files with 11 additions and 2 deletions
|
@ -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;
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue