MM-62978 Remove alt text from profile picture in File Preview modal (#33584)

* MM-62978 Remove alt text from profile picture in File Preview modal

* Update snapshots
This commit is contained in:
Harrison Healey
2025-08-08 10:22:07 -04:00
committed by GitHub
parent 0e39bbe675
commit 3ab9a661c1
3 changed files with 12 additions and 1 deletions
@@ -5,6 +5,7 @@ exports[`components/FilePreviewModalInfo should match snapshot 1`] = `
className="file-preview-modal__info"
>
<Memo(Avatar)
alt=""
className="file-preview-modal__avatar"
size="lg"
url="/api/v4/users/user_id/image?_=0"
@@ -79,6 +79,7 @@ const FilePreviewModalInfo: React.FC<Props> = (props: Props) => {
username={user?.username}
url={imageURLForUser(props.post.user_id, user?.last_picture_update)}
className='file-preview-modal__avatar'
alt=''
/>
}
@@ -43,6 +43,14 @@ type Props = {
username?: string;
size?: TAvatarSizeToken;
text?: string;
/**
* Override the default alt text for the image.
*
* If this Avatar is accompanied in the DOM by the user's name, this should be set to the empty string to prevent
* screen readers from repeating the user's name multiple times.
*/
alt?: string;
};
type Attrs = HTMLAttributes<HTMLElement>;
@@ -55,6 +63,7 @@ const Avatar = forwardRef<HTMLElement, Props & Attrs>(({
username,
size = 'md',
text,
alt,
...attrs
}, ref) => {
const {formatMessage} = useIntl();
@@ -85,7 +94,7 @@ const Avatar = forwardRef<HTMLElement, Props & Attrs>(({
{...attrs}
ref={ref as RefObject<HTMLImageElement>}
className={classes}
alt={formatMessage({id: 'avatar.alt', defaultMessage: '{username} profile image'}, {
alt={alt ?? formatMessage({id: 'avatar.alt', defaultMessage: '{username} profile image'}, {
username: username || 'user',
})}
src={url}