From a03cbd8b1a32f38618356c3b8d1f375b9ad5bdce Mon Sep 17 00:00:00 2001 From: Spence Pope Date: Tue, 12 May 2026 11:17:46 -0400 Subject: [PATCH] [APP-2170] Render GIFs through ConstrainedImage (#10453) Co-authored-by: vineyardbovines --- .../Post/Embed/ExternalEmbed/Gif.tsx | 104 +++++++++--------- src/view/com/composer/GifAltText.tsx | 17 ++- 2 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/components/Post/Embed/ExternalEmbed/Gif.tsx b/src/components/Post/Embed/ExternalEmbed/Gif.tsx index 478d63d250..4cf95e0fab 100644 --- a/src/components/Post/Embed/ExternalEmbed/Gif.tsx +++ b/src/components/Post/Embed/ExternalEmbed/Gif.tsx @@ -1,13 +1,13 @@ import {useRef, useState} from 'react' -import {type StyleProp, View, type ViewStyle} from 'react-native' +import {View} from 'react-native' import {msg} from '@lingui/core/macro' import {useLingui} from '@lingui/react' -import {clamp} from '#/lib/numbers' import {type EmbedPlayerParams} from '#/lib/strings/embed-player' import {useAutoplayDisabled} from '#/state/preferences' import {atoms as a, useTheme} from '#/alf' import {Fill} from '#/components/Fill' +import {ConstrainedImage} from '#/components/images/AutoSizedImage' import {MediaInsetBorder} from '#/components/MediaInsetBorder' import {GifView} from '../../../../../modules/expo-bluesky-gif-view' import {type GifViewStateChangeEvent} from '../../../../../modules/expo-bluesky-gif-view/src/GifView.types' @@ -19,14 +19,12 @@ export function GifEmbed({ altText, isPreferredAltText, hideAlt, - style = {width: '100%'}, }: { params: EmbedPlayerParams thumb: string | undefined altText: string isPreferredAltText: boolean hideAlt?: boolean - style?: StyleProp }) { const t = useTheme() const {_} = useLingui() @@ -53,60 +51,64 @@ export function GifEmbed({ let aspectRatio = 1 if (params.dimensions) { const ratio = params.dimensions.width / params.dimensions.height - aspectRatio = clamp(ratio, 0.75, 4) + if (!Number.isNaN(ratio)) { + aspectRatio = ratio + } } + const constrained = Math.max(aspectRatio, 1 / 2) return ( - + - - - - {!playerState.isPlaying && ( - + + - )} + + {!playerState.isPlaying && ( + + )} + - + ) } diff --git a/src/view/com/composer/GifAltText.tsx b/src/view/com/composer/GifAltText.tsx index 275b4be89a..b7565e6b6d 100644 --- a/src/view/com/composer/GifAltText.tsx +++ b/src/view/com/composer/GifAltText.tsx @@ -216,16 +216,13 @@ function AltTextInner({ style={[a.text_2xl, a.font_semi_bold, a.leading_tight, a.pb_sm]}> Add alt text - - - +