Refac preemptive image fallback when url is undefined. Ticket: #911

This commit is contained in:
MerlinScheurer
2025-03-28 01:34:34 +01:00
parent 0aa5ef5b31
commit 2be190aa65
5 changed files with 35 additions and 5 deletions

View File

@@ -7,9 +7,15 @@ type ChannelIconProps = {
};
const ChannelIcon = ({ channelId, channelThumbUrl }: ChannelIconProps) => {
let src = `${getApiUrl()}${channelThumbUrl}`;
if (channelThumbUrl === undefined) {
src = defaultChannelIcon;
}
return (
<img
src={`${getApiUrl()}${channelThumbUrl}`}
src={src}
alt={`${channelId}-thumb`}
onError={({ currentTarget }) => {
currentTarget.onerror = null; // prevents looping