Skip to content

Commit

Permalink
site: Fix filtering for players without avatars
Browse files Browse the repository at this point in the history
If a player doesn't hae an aatar, then avatarhash would be null, causing an
exception. Check for this, and just skip the avatar image in that case.

Fixes: 07c6e92 ("site: Add avatars to player filters")
Signed-off-by: Sean Anderson <[email protected]>
  • Loading branch information
Forty-Bot committed Feb 23, 2024
1 parent 5d18fa8 commit 8ab119f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions trends/site/static/js/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ document.addEventListener('DOMContentLoaded', () => {

function render_option(data, escape) {
let div = document.createElement('div');
let img = document.createElement('img');
img.classList.add('avatar_small');
img.setAttribute('src', "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/" +
`avatars/${data.avatarhash.slice(0, 2)}/${data.avatarhash}.jpg`);
div.append(img, " ", data.name);
if (data.avatarhash == null) {
div.append(data.name);
} else {
let img = document.createElement('img');
img.classList.add('avatar_small');
img.setAttribute('src', "https://steamcdn-a.akamaihd.net/steamcommunity/public/"
`images/avatars/${data.avatarhash.slice(0, 2)}/` +
`${data.avatarhash}.jpg`);
div.append(img, " ", data.name);
}
return div;
}

Expand Down

0 comments on commit 8ab119f

Please sign in to comment.