From 56af5a26dd421ddbccf0a05b3d7889063f737465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Mon, 27 Oct 2025 05:25:33 +0100 Subject: [PATCH] pl-fe: support static url in StillImage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/components/still-image.tsx | 24 +++++++++++-------- packages/pl-fe/src/components/ui/emoji.tsx | 4 +++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/pl-fe/src/components/still-image.tsx b/packages/pl-fe/src/components/still-image.tsx index 92ab71e67..2ed9d9998 100644 --- a/packages/pl-fe/src/components/still-image.tsx +++ b/packages/pl-fe/src/components/still-image.tsx @@ -12,6 +12,8 @@ interface IStillImage { innerClassName?: string; /** URL to the image */ src: string; + /** URL to the static image */ + staticSrc?: string; /** Extra CSS styles on the outer
element. */ style?: React.CSSProperties; /** Whether to display the image contained vs filled in its container. */ @@ -30,19 +32,17 @@ interface IStillImage { /** Renders images on a canvas, only playing GIFs if autoPlayGif is enabled. */ const StillImage: React.FC = ({ - alt, className, innerClassName, src, style, letterboxed = false, showExt = false, onError, onLoad, isGif, noGroup, + alt, className, innerClassName, src, staticSrc, style, letterboxed = false, showExt = false, onError, onLoad, isGif, noGroup, }) => { const { autoPlayGif } = useSettings(); const canvas = useRef(null); const img = useRef(null); - const hoverToPlay = ( - src && !autoPlayGif && ((isGif) || src.endsWith('.gif') || src.startsWith('blob:')) - ); + const hoverToPlay = src && !autoPlayGif && ((isGif) || src.endsWith('.gif') || src.startsWith('blob:') || (src && staticSrc && src !== staticSrc)); const handleImageLoad: React.ReactEventHandler = (e) => { - if (hoverToPlay && canvas.current && img.current) { + if (hoverToPlay && !staticSrc && canvas.current && img.current) { canvas.current.width = img.current.naturalWidth; canvas.current.height = img.current.naturalHeight; const context = canvas.current.getContext('2d'); @@ -80,14 +80,18 @@ const StillImage: React.FC = ({ })} /> - {hoverToPlay && ( + {hoverToPlay && (staticSrc ? ( + {alt} + ) : ( - )} + ))} {(hoverToPlay && showExt) && (
diff --git a/packages/pl-fe/src/components/ui/emoji.tsx b/packages/pl-fe/src/components/ui/emoji.tsx index 367a3ac71..1a79e2626 100644 --- a/packages/pl-fe/src/components/ui/emoji.tsx +++ b/packages/pl-fe/src/components/ui/emoji.tsx @@ -9,12 +9,13 @@ interface IEmoji extends Pick, 'alt' | /** Unicode emoji character. */ emoji?: string; noGroup?: boolean; + staticSrc?: string; } /** A single emoji image. */ const Emoji: React.FC = (props): JSX.Element | null => { const { disableUserProvidedMedia, systemEmojiFont } = useSettings(); - const { emoji, alt, src, noGroup, ...rest } = props; + const { emoji, alt, src, staticSrc, noGroup, ...rest } = props; let filename; @@ -35,6 +36,7 @@ const Emoji: React.FC = (props): JSX.Element | null => {