Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a0e8c29

Browse files
authored
Make image size constrained by height when using the ImageSize.Large option (#7171)
1 parent d7f3d27 commit a0e8c29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/components/views/messages/MImageBody.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,15 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
379379
// check for any height constraints
380380
const imageSize = SettingsStore.getValue("Images.size") as ImageSize;
381381
const suggestedAndPossibleWidth = Math.min(suggestedImageSize(imageSize).w, infoWidth);
382+
const suggestedAndPossibleHeight = Math.min(suggestedImageSize(imageSize).h, infoHeight);
382383
const aspectRatio = infoWidth / infoHeight;
383384

384385
let maxWidth;
385386
let maxHeight;
386-
const maxHeightConstraint = forcedHeight || this.props.maxImageHeight || undefined;
387-
if (maxHeightConstraint && maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth) {
387+
const maxHeightConstraint = forcedHeight || this.props.maxImageHeight || suggestedAndPossibleHeight;
388+
if (maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth || imageSize === ImageSize.Large) {
388389
// width is dictated by the maximum height that was defined by the props or the function param `forcedHeight`
390+
// If the thumbnail size is set to Large, we always let the size be dictated by the height.
389391
maxWidth = maxHeightConstraint * aspectRatio;
390392
// there is no need to check for infoHeight here since this is done with `maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth`
391393
maxHeight = maxHeightConstraint;

0 commit comments

Comments
 (0)