From 7bd012a93ca1b179872b719486ddfd64320f726e Mon Sep 17 00:00:00 2001 From: Timo K Date: Sat, 20 Nov 2021 20:15:45 +0100 Subject: [PATCH] image size height constraint fix (for imageSize.Large) --- src/components/views/messages/MImageBody.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/messages/MImageBody.tsx b/src/components/views/messages/MImageBody.tsx index 543c3832830..6e3ddb636cc 100644 --- a/src/components/views/messages/MImageBody.tsx +++ b/src/components/views/messages/MImageBody.tsx @@ -379,13 +379,15 @@ export default class MImageBody extends React.Component { // check for any height constraints const imageSize = SettingsStore.getValue("Images.size") as ImageSize; const suggestedAndPossibleWidth = Math.min(suggestedImageSize(imageSize).w, infoWidth); + const suggestedAndPossibleHeight = Math.min(suggestedImageSize(imageSize).h, infoHeight); const aspectRatio = infoWidth / infoHeight; let maxWidth; let maxHeight; - const maxHeightConstraint = forcedHeight || this.props.maxImageHeight || undefined; - if (maxHeightConstraint && maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth) { + const maxHeightConstraint = forcedHeight || this.props.maxImageHeight || suggestedAndPossibleHeight; + if (maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth || imageSize === ImageSize.Large) { // width is dictated by the maximum height that was defined by the props or the function param `forcedHeight` + // If the thumbnail size is set to Large, we always let the size be dictated by the height. maxWidth = maxHeightConstraint * aspectRatio; // there is no need to check for infoHeight here since this is done with `maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth` maxHeight = maxHeightConstraint;