Fix avatars not using image tags in web UI (#19488)

Fix #19483
This commit is contained in:
Eugen Rochko
2022-10-28 00:48:45 +02:00
committed by GitHub
parent 07cc201acc
commit 8dfe5179ee
6 changed files with 103 additions and 79 deletions

View File

@ -42,30 +42,20 @@ export default class Avatar extends React.PureComponent {
...this.props.style,
width: `${size}px`,
height: `${size}px`,
backgroundSize: `${size}px ${size}px`,
};
if (account) {
const src = account.get('avatar');
const staticSrc = account.get('avatar_static');
let src;
if (hovering || animate) {
style.backgroundImage = `url(${src})`;
} else {
style.backgroundImage = `url(${staticSrc})`;
}
if (hovering || animate) {
src = account?.get('avatar');
} else {
src = account?.get('avatar_static');
}
return (
<div
className={classNames('account__avatar', { 'account__avatar-inline': inline })}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
style={style}
role='img'
aria-label={account?.get('acct')}
/>
<div className={classNames('account__avatar', { 'account__avatar-inline': inline })} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave} style={style}>
<img src={src} alt={account?.get('acct')} />
</div>
);
}