Introduce ImageOrBlurhash component

This commit is contained in:
Fedor Indutny
2025-08-04 09:16:54 -07:00
committed by GitHub
parent 85f472741b
commit 313d832542
4 changed files with 246 additions and 10 deletions

View File

@@ -4,8 +4,8 @@
import type { CSSProperties } from 'react';
import React, { useCallback } from 'react';
import classNames from 'classnames';
import { Blurhash } from 'react-blurhash';
import { ImageOrBlurhash } from '../ImageOrBlurhash';
import { Spinner } from '../Spinner';
import type { LocalizerType, ThemeType } from '../../types/Util';
import type { AttachmentForUIType } from '../../types/Attachment';
@@ -169,21 +169,17 @@ export function Image({
showMediaNoLongerAvailableToast
);
const imageOrBlurHash = url ? (
<img
const imageOrBlurHash = (
<ImageOrBlurhash
onError={onError}
className="module-image__image"
alt={alt}
height={height}
width={width}
intrinsicWidth={attachment.width}
intrinsicHeight={attachment.height}
src={url}
/>
) : (
<Blurhash
hash={resolvedBlurHash}
width={width}
height={height}
style={{ display: 'block' }}
blurHash={resolvedBlurHash}
/>
);