Add loading="lazy" to expo-image on web (#9480)

* add `loading="lazy"` to expo-image

* add `loading="lazy"` to embed cards, avatars

* get rid of useless image wrapper indirection

* move image components to components dir

* fix imports

* fix import

* Keep avis eager

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
Samuel Newman
2026-01-15 04:29:13 +02:00
committed by GitHub
parent f960d2fbc6
commit 1cb362b596
12 changed files with 122 additions and 31 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
import {memo, useCallback, useMemo, useState} from 'react'
import {
Image,
Image as RNImage,
Pressable,
type StyleProp,
StyleSheet,
@@ -8,6 +8,7 @@ import {
type ViewStyle,
} from 'react-native'
import Svg, {Circle, Path, Rect} from 'react-native-svg'
import {Image as ExpoImage} from 'expo-image'
import {type ModerationUI} from '@atproto/api'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {msg, Trans} from '@lingui/macro'
@@ -37,7 +38,6 @@ import {
} from '#/state/gallery'
import {unstableCacheProfileView} from '#/state/queries/unstable-profile-cache'
import {EditImageDialog} from '#/view/com/composer/photos/EditImageDialog'
import {HighPriorityImage} from '#/view/com/util/images/Image'
import {atoms as a, tokens, useTheme} from '#/alf'
import {Button} from '#/components/Button'
import {useDialogControl} from '#/components/Dialog'
@@ -289,7 +289,7 @@ let UserAvatar = ({
!((moderation?.blur && isAndroid) /* android crashes with blur */) ? (
<View style={containerStyle}>
{usePlainRNImage ? (
<Image
<RNImage
accessibilityIgnoresInvertColors
testID="userAvatarImage"
style={aviStyle}
@@ -301,7 +301,7 @@ let UserAvatar = ({
onLoad={onLoad}
/>
) : (
<HighPriorityImage
<ExpoImage
testID="userAvatarImage"
style={aviStyle}
contentFit="cover"
@@ -441,7 +441,7 @@ let EditableUserAvatar = ({
{({props}) => (
<Pressable {...props} testID="changeAvatarBtn">
{avatar ? (
<HighPriorityImage
<ExpoImage
testID="userAvatarImage"
style={aviStyle}
source={{uri: avatar}}