fix: skin/cape image loading with error handling
All checks were successful
CI / lint (push) Successful in 17s
CI / test (push) Successful in 43s
CI / build (push) Successful in 18s
CI / docker (push) Successful in 1m10s

This commit is contained in:
2026-06-06 20:00:26 +03:00
parent 6a8213a234
commit 329c0d3fda

View File

@@ -95,9 +95,11 @@
// Skin
if (data.textures && data.textures.skin) {
document.getElementById('skinImg').src = '/skins/' + data.textures.skin_hash;
document.getElementById('skinImg').style.display = 'inline';
document.getElementById('noSkinMsg').style.display = 'none';
const skinImg = document.getElementById('skinImg');
const noSkinMsg = document.getElementById('noSkinMsg');
skinImg.onerror = function() { this.style.display = 'none'; noSkinMsg.style.display = 'block'; };
skinImg.onload = function() { this.style.display = 'inline'; noSkinMsg.style.display = 'none'; };
skinImg.src = '/skins/' + data.textures.skin_hash;
} else {
document.getElementById('skinImg').style.display = 'none';
document.getElementById('noSkinMsg').style.display = 'block';
@@ -105,9 +107,11 @@
// Cape
if (data.textures && data.textures.cape) {
document.getElementById('capeImg').src = '/skins/' + data.textures.cape_hash;
document.getElementById('capeImg').style.display = 'inline';
document.getElementById('noCapeMsg').style.display = 'none';
const capeImg = document.getElementById('capeImg');
const noCapeMsg = document.getElementById('noCapeMsg');
capeImg.onerror = function() { this.style.display = 'none'; noCapeMsg.style.display = 'block'; };
capeImg.onload = function() { this.style.display = 'inline'; noCapeMsg.style.display = 'none'; };
capeImg.src = '/skins/' + data.textures.cape_hash;
} else {
document.getElementById('capeImg').style.display = 'none';
document.getElementById('noCapeMsg').style.display = 'block';