diff --git a/src/components/common/helpers/mediaDimensions.ts b/src/components/common/helpers/mediaDimensions.ts index c5f69a4c..9334b45c 100644 --- a/src/components/common/helpers/mediaDimensions.ts +++ b/src/components/common/helpers/mediaDimensions.ts @@ -10,6 +10,7 @@ import { getPhotoInlineDimensions, getVideoDimensions } from '../../../modules/h export const MEDIA_VIEWER_MEDIA_QUERY = '(max-height: 640px)'; export const REM = parseInt(getComputedStyle(document.documentElement).fontSize, 10); export const ROUND_VIDEO_DIMENSIONS = 240; +export const GIF_MIN_WIDTH = 300; export const AVATAR_FULL_DIMENSIONS = { width: 640, height: 640 }; export const LIKE_STICKER_ID = '1258816259753933'; @@ -99,8 +100,10 @@ function calculateDimensionsForMessageMedia({ const aspectRatio = height / width; const availableWidth = getAvailableWidth(fromOwnMessage, isForwarded, isWebPagePhoto, noAvatars); const availableHeight = getAvailableHeight(isGif, aspectRatio); + const mediaWidth = isGif ? Math.max(GIF_MIN_WIDTH, width) : width; + const mediaHeight = isGif ? height * (mediaWidth / width) : height; - return calculateDimensions(availableWidth, availableHeight, width, height); + return calculateDimensions(availableWidth, availableHeight, mediaWidth, mediaHeight); } export function getMediaViewerAvailableDimensions(withFooter: boolean, isVideo: boolean): ApiDimensions {