mirror of
https://github.com/RGBCube/cinny
synced 2025-08-02 09:57:46 +00:00
Add broken avatar fallback
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
62c9e271d8
commit
f0c9a458bb
2 changed files with 21 additions and 1 deletions
|
@ -7,6 +7,8 @@ import { twemojify } from '../../../util/twemojify';
|
|||
import Text from '../text/Text';
|
||||
import RawIcon from '../system-icons/RawIcon';
|
||||
|
||||
import ImageBrokenSVG from '../../../../public/res/svg/image-broken.svg';
|
||||
|
||||
function Avatar({
|
||||
text, bgColor, iconSrc, iconColor, imageSrc, size,
|
||||
}) {
|
||||
|
@ -19,7 +21,7 @@ function Avatar({
|
|||
<div className={`avatar-container avatar-container__${size} noselect`}>
|
||||
{
|
||||
imageSrc !== null
|
||||
? <img draggable="false" src={imageSrc} alt="avatar" />
|
||||
? <img draggable="false" src={imageSrc} onError={(e) => { e.target.src = ImageBrokenSVG; }} alt="avatar" />
|
||||
: (
|
||||
<span
|
||||
style={{ backgroundColor: iconSrc === null ? bgColor : 'transparent' }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue