diff --git a/x-pack/plugins/uptime/public/components/synthetics/step_screenshot_display.tsx b/x-pack/plugins/uptime/public/components/synthetics/step_screenshot_display.tsx index 1224a31cfabb4..8b4a116f34967 100644 --- a/x-pack/plugins/uptime/public/components/synthetics/step_screenshot_display.tsx +++ b/x-pack/plugins/uptime/public/components/synthetics/step_screenshot_display.tsx @@ -16,7 +16,7 @@ import { import styled from 'styled-components'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import React, { useContext, useEffect, useRef, useState, FC } from 'react'; +import React, { useContext, useEffect, useMemo, useRef, useState, FC } from 'react'; import useIntersection from 'react-use/lib/useIntersection'; import { isScreenshotRef as isAScreenshotRef, @@ -36,16 +36,13 @@ interface StepScreenshotDisplayProps { lazyLoad?: boolean; } -const IMAGE_WIDTH = 640; -const IMAGE_HEIGHT = 360; +const IMAGE_MAX_WIDTH = 640; const StepImage = styled(EuiImage)` &&& { figcaption { display: none; } - width: ${IMAGE_WIDTH}, - height: ${IMAGE_HEIGHT}, objectFit: 'cover', objectPosition: 'center top', } @@ -139,11 +136,22 @@ export const StepScreenshotDisplay: FC = ({ } }, [basePath, checkGroup, stepIndex, isScreenshotRef]); + const refDimensions = useMemo(() => { + if (isAScreenshotRef(screenshotRef)) { + const { height, width } = screenshotRef.ref.screenshotRef.screenshot_ref; + return { height, width }; + } + }, [screenshotRef]); + const shouldRenderImage = hasIntersected || !lazyLoad; return (
{shouldRenderImage && isScreenshotBlob && (