diff --git a/web/src/components/CameraImage.jsx b/web/src/components/CameraImage.jsx index 98754e506..ce4e4bef7 100644 --- a/web/src/components/CameraImage.jsx +++ b/web/src/components/CameraImage.jsx @@ -28,13 +28,18 @@ export default function CameraImage({ camera, onload, searchParams = '', stretch const scaledHeight = useMemo(() => { const scaledHeight = Math.floor(availableWidth / aspectRatio); - return stretch ? scaledHeight : Math.min(scaledHeight, height); + const finalHeight = stretch ? scaledHeight : Math.min(scaledHeight, height); + + if (finalHeight > 0) { + return finalHeight; + } + + return 100; }, [availableWidth, aspectRatio, height, stretch]); - const scaledWidth = useMemo(() => Math.ceil(scaledHeight * aspectRatio - scrollBarWidth), [ - scaledHeight, - aspectRatio, - scrollBarWidth, - ]); + const scaledWidth = useMemo( + () => Math.ceil(scaledHeight * aspectRatio - scrollBarWidth), + [scaledHeight, aspectRatio, scrollBarWidth] + ); const img = useMemo(() => new Image(), []); img.onload = useCallback( @@ -58,18 +63,16 @@ export default function CameraImage({ camera, onload, searchParams = '', stretch return (