Make image size constrained by height when using the ImageSize.Large option (#7171)
parent
d7f3d2791a
commit
a0e8c29d85
|
@ -379,13 +379,15 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
// check for any height constraints
|
// check for any height constraints
|
||||||
const imageSize = SettingsStore.getValue("Images.size") as ImageSize;
|
const imageSize = SettingsStore.getValue("Images.size") as ImageSize;
|
||||||
const suggestedAndPossibleWidth = Math.min(suggestedImageSize(imageSize).w, infoWidth);
|
const suggestedAndPossibleWidth = Math.min(suggestedImageSize(imageSize).w, infoWidth);
|
||||||
|
const suggestedAndPossibleHeight = Math.min(suggestedImageSize(imageSize).h, infoHeight);
|
||||||
const aspectRatio = infoWidth / infoHeight;
|
const aspectRatio = infoWidth / infoHeight;
|
||||||
|
|
||||||
let maxWidth;
|
let maxWidth;
|
||||||
let maxHeight;
|
let maxHeight;
|
||||||
const maxHeightConstraint = forcedHeight || this.props.maxImageHeight || undefined;
|
const maxHeightConstraint = forcedHeight || this.props.maxImageHeight || suggestedAndPossibleHeight;
|
||||||
if (maxHeightConstraint && maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth) {
|
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`
|
// 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;
|
maxWidth = maxHeightConstraint * aspectRatio;
|
||||||
// there is no need to check for infoHeight here since this is done with `maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth`
|
// there is no need to check for infoHeight here since this is done with `maxHeightConstraint * aspectRatio < suggestedAndPossibleWidth`
|
||||||
maxHeight = maxHeightConstraint;
|
maxHeight = maxHeightConstraint;
|
||||||
|
|
Loading…
Reference in New Issue