Add broken avatar fallback

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-01-16 10:41:37 +05:30
parent 62c9e271d8
commit f0c9a458bb
2 changed files with 21 additions and 1 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g>
<g>
<polygon fill="#7F7F7F" points="20,7 20,5 18,5 18,7 16,7 16,5 18,5 18,3 16,3 16,2 3,2 3,22 11,22 11,20 19,12 21,12 21,7 "/>
<polygon fill="#7F7F7F" points="19,16 21,16 21,22 15,22 15,20 19,20 "/>
</g>
<polygon fill="#6FBEFF" points="19,9 14,9 14,4 5,4 5,20 11,20 13,20 13,18 15,18 15,16 17,16 17,14 19,14 "/>
<polygon fill="#FFFFFF" points="7,10 12,10 12,8 10,8 10,7 8,7 8,8 7,8 "/>
<g>
<rect x="17" y="18" fill="#00C72C" width="2" height="2"/>
<polygon fill="#00C72C" points="5,20 5,18 7,18 7,16 9,16 9,14 11,14 11,12 13,12 13,14 15,14 15,18 13,18 13,20 "/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -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' }}