From afe5db8b575e0119077cdedf9a836e825f11772c Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 30 Dec 2025 11:30:49 +0200 Subject: [PATCH] clamp gif size (#9610) --- src/components/Post/Embed/ExternalEmbed/Gif.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Post/Embed/ExternalEmbed/Gif.tsx b/src/components/Post/Embed/ExternalEmbed/Gif.tsx index 8e84997314..1e5e8975e3 100644 --- a/src/components/Post/Embed/ExternalEmbed/Gif.tsx +++ b/src/components/Post/Embed/ExternalEmbed/Gif.tsx @@ -11,6 +11,7 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {HITSLOP_20} from '#/lib/constants' +import {clamp} from '#/lib/numbers' import {type EmbedPlayerParams} from '#/lib/strings/embed-player' import {isWeb} from '#/platform/detection' import {useAutoplayDisabled} from '#/state/preferences' @@ -111,6 +112,15 @@ export function GifEmbed({ playerRef.current?.toggleAsync() }, []) + let aspectRatio = 1 + if (params.dimensions) { + aspectRatio = clamp( + params.dimensions.width / params.dimensions.height, + 0.75, + 4, + ) + } + return (