diff --git a/src/components/middle/message/Photo.tsx b/src/components/middle/message/Photo.tsx index cfe3b9f26..d17463698 100644 --- a/src/components/middle/message/Photo.tsx +++ b/src/components/middle/message/Photo.tsx @@ -41,6 +41,7 @@ export type OwnProps = { nonInteractive?: boolean; isDownloading: boolean; isProtected?: boolean; + withAspectRatio?: boolean; theme: ISettings['theme']; onClick?: (id: number) => void; onCancelUpload?: (message: ApiMessage) => void; @@ -61,6 +62,7 @@ const Photo: FC = ({ shouldAffectAppendix, isDownloading, isProtected, + withAspectRatio, theme, onClick, onCancelUpload, @@ -143,8 +145,9 @@ const Photo: FC = ({ width === height && 'square-image', ); + const aspectRatio = withAspectRatio ? `aspect-ratio: ${(width / height).toFixed(3)}/ 1` : ''; const style = dimensions - ? `width: ${width}px; height: ${height}px; left: ${dimensions.x}px; top: ${dimensions.y}px;` + ? `width: ${width}px; height: ${height}px; left: ${dimensions.x}px; top: ${dimensions.y}px;${aspectRatio}` : ''; return ( @@ -158,7 +161,7 @@ const Photo: FC = ({ void; onCancelUpload?: (message: ApiMessage) => void; }; @@ -61,6 +62,7 @@ const Video: FC = ({ onCancelUpload, isDownloading, isProtected, + withAspectRatio, }) => { // eslint-disable-next-line no-null/no-null const ref = useRef(null); @@ -150,10 +152,10 @@ const Video: FC = ({ }, [isUploading, isDownloading, fullMediaData, isPlayAllowed, onClick, onCancelUpload, message]); const className = buildClassName('media-inner dark', !isUploading && 'interactive'); + const aspectRatio = withAspectRatio ? `aspect-ratio: ${(width / height).toFixed(3)}/ 1` : ''; const style = dimensions - ? `width: ${width}px; height: ${height}px; left: ${dimensions.x}px; top: ${dimensions.y}px;` + ? `width: ${width}px; height: ${height}px; left: ${dimensions.x}px; top: ${dimensions.y}px;${aspectRatio}` : ''; - return (
= ({ @@ -188,6 +190,7 @@ const Video: FC = ({ {...bufferingHandlers} draggable={!isProtected} onTimeUpdate={handleTimeUpdate} + style={aspectRatio} > diff --git a/src/components/middle/message/WebPage.scss b/src/components/middle/message/WebPage.scss index ff13e7a85..549eb5288 100644 --- a/src/components/middle/message/WebPage.scss +++ b/src/components/middle/message/WebPage.scss @@ -123,4 +123,18 @@ right: 0; } } + + @media (min-width: 1921px) { + @supports (aspect-ratio: 1) { + &:not(.in-preview) { + max-width: none; + + .thumbnail, + .full-media { + width: 100% !important; + height: auto !important; + } + } + } + } } diff --git a/src/components/middle/message/WebPage.tsx b/src/components/middle/message/WebPage.tsx index 838e04334..f735affe1 100644 --- a/src/components/middle/message/WebPage.tsx +++ b/src/components/middle/message/WebPage.tsx @@ -77,6 +77,7 @@ const WebPage: FC = ({ const className = buildClassName( 'WebPage', + inPreview && 'in-preview', isSquarePhoto && 'with-square-photo', !photo && !video && !inPreview && 'without-media', video && 'with-video', @@ -100,6 +101,7 @@ const WebPage: FC = ({ onCancelUpload={onCancelMediaTransfer} isDownloading={isDownloading} isProtected={isProtected} + withAspectRatio theme={theme} /> )} @@ -124,6 +126,7 @@ const WebPage: FC = ({ onCancelUpload={onCancelMediaTransfer} isDownloading={isDownloading} isProtected={isProtected} + withAspectRatio /> )}