Use AutoSizedImage for screen reader view

This commit is contained in:
Eric Bailey
2026-04-08 10:42:09 -05:00
parent ff492efd5f
commit 23bafcfb29
+20 -48
View File
@@ -12,6 +12,7 @@ import {type Dimensions} from '#/lib/media/types'
import {useA11y} from '#/state/a11y' import {useA11y} from '#/state/a11y'
import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge' import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {AutoSizedImage} from '#/components/images/AutoSizedImage'
import {MediaInsetBorder} from '#/components/MediaInsetBorder' import {MediaInsetBorder} from '#/components/MediaInsetBorder'
import {PostEmbedViewContext} from '#/components/Post/Embed/types' import {PostEmbedViewContext} from '#/components/Post/Embed/types'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
@@ -96,55 +97,26 @@ export function Gallery({
if (screenReaderEnabled) { if (screenReaderEnabled) {
return ( return (
<View <View style={[a.relative, a.gap_sm]}>
style={[a.rounded_md, a.overflow_hidden]}
accessibilityRole="adjustable">
{images.map((image, index) => ( {images.map((image, index) => (
<View <AutoSizedImage
key={index} key={image.thumb}
ref={containerRefs[index]} crop={
collapsable={false} viewContext === PostEmbedViewContext.ThreadHighlighted
style={[ ? 'none'
{aspectRatio: CONTAINER_ASPECT_RATIO}, : viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
t.atoms.bg_contrast_25, ? 'square'
]}> : 'constrained'
<Pressable }
onPress={ image={image}
onPress onPress={(containerRef, dims) =>
? () => onPress?.(index, [containerRef], [dims])
onPress( }
index, onPressIn={() => onPressIn?.(index)}
containerRefs.slice(0, images.length), hideBadge={
thumbDimsRef.current.slice(), viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
) }
: undefined />
}
onPressIn={onPressIn ? () => onPressIn(index) : undefined}
accessibilityRole="button"
accessibilityLabel={
image.alt || l`Image ${index + 1} of ${images.length}`
}
accessibilityHint={l`Opens full image`}
style={[a.flex_1]}>
<Image
source={{uri: image.thumb}}
style={[a.flex_1]}
contentFit="cover"
accessible={true}
accessibilityLabel={image.alt}
accessibilityHint=""
accessibilityIgnoresInvertColors
onLoad={e => {
thumbDimsRef.current[index] = {
width: e.source.width,
height: e.source.height,
}
}}
loading={index === 0 ? 'eager' : 'lazy'}
/>
<MediaInsetBorder />
</Pressable>
</View>
))} ))}
</View> </View>
) )