Use the placeholder image if there is no valid mxc uri

This commit is contained in:
Kegan Dougal 2021-10-08 16:33:25 +01:00
parent e98dbccf31
commit f9ed9ddd8c

View File

@ -198,7 +198,7 @@ const renderRoomContent = (roomId, refresh) => {
}
document.getElementById("selectedroomname").textContent = room.name || room.room_id;
if (room.avatar) {
document.getElementById("selectedroomavatar").src = mxcToUrl(room.avatar);
document.getElementById("selectedroomavatar").src = mxcToUrl(room.avatar) || "/client/placeholder.svg";
} else {
document.getElementById("selectedroomavatar").src = "/client/placeholder.svg";
}
@ -266,7 +266,7 @@ const render = (container) => {
roomNameSpan.style = "";
roomContentSpan.style = "";
if (r.avatar) {
roomCell.getElementsByClassName("roomavatar")[0].src = mxcToUrl(r.avatar);
roomCell.getElementsByClassName("roomavatar")[0].src = mxcToUrl(r.avatar) || "/client/placeholder.svg";
} else {
roomCell.getElementsByClassName("roomavatar")[0].src = "/client/placeholder.svg";
}
@ -532,6 +532,9 @@ const zeroPad = (n) => {
const mxcToUrl = (mxc) => {
const path = mxc.substr("mxc://".length);
if (!path) {
return;
}
// TODO: we should really use the proxy HS not matrix.org
return `https://matrix-client.matrix.org/_matrix/media/r0/thumbnail/${path}?width=64&height=64&method=crop`;
}