mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Add blurhash user background for Most Active Users card
This commit is contained in:
parent
b19b9a70be
commit
74d6b18b47
4 changed files with 44 additions and 3 deletions
|
@ -872,4 +872,40 @@ function short_season(title) {
|
|||
return 'S' + title.substring(7)
|
||||
}
|
||||
return title
|
||||
}
|
||||
}
|
||||
|
||||
function loadAllBlurHash() {
|
||||
$('[data-blurhash]').each(function() {
|
||||
const elem = $(this);
|
||||
const src = elem.data('blurhash');
|
||||
loadBlurHash(elem, src);
|
||||
});
|
||||
}
|
||||
|
||||
function loadBlurHash(elem, src) {
|
||||
const img = new Image();
|
||||
img.src = src;
|
||||
img.onload = () => {
|
||||
const imgData = blurhash.getImageData(img);
|
||||
|
||||
blurhash
|
||||
.encodePromise(imgData, img.width, img.height, 4, 4)
|
||||
.then(hash => {
|
||||
return blurhash.decodePromise(
|
||||
hash,
|
||||
img.width,
|
||||
img.height
|
||||
);
|
||||
})
|
||||
.then(blurhashImgData => {
|
||||
const imgObject = blurhash.getImageDataAsImage(
|
||||
blurhashImgData,
|
||||
img.width,
|
||||
img.height,
|
||||
(event, imgObject) => {
|
||||
elem.css('background-image', 'url(' + imgObject.src + ')')
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue