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

Commit 866a11d

Browse files
committed
Fix image alignment issues
Signed-off-by: Šimon Brandner <[email protected]>
1 parent fca5125 commit 866a11d

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

res/css/views/messages/_MImageReplyBody.scss

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ limitations under the License.
1515
*/
1616

1717
.mx_MImageReplyBody {
18-
display: grid;
19-
grid-template:
20-
"image sender" 20px
21-
"image filename" 20px
22-
/ 44px auto;
23-
grid-gap: 4px;
24-
}
25-
26-
.mx_MImageReplyBody_thumbnail {
27-
grid-area: image;
18+
display: flex;
2819

2920
.mx_MImageBody_thumbnail_container {
30-
max-height: 44px !important;
21+
flex: 1;
22+
padding-right: 4px;
3123
}
3224
}
3325

src/components/views/messages/MImageBody.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,12 @@ export default class MImageBody extends React.Component<IProps, IState> {
332332
_afterComponentWillUnmount() {
333333
}
334334

335-
protected messageContent(contentUrl: string, thumbUrl: string, content: IMediaEventContent): JSX.Element {
335+
protected messageContent(
336+
contentUrl: string,
337+
thumbUrl: string,
338+
content: IMediaEventContent,
339+
forcedHeight?: number,
340+
): JSX.Element {
336341
let infoWidth;
337342
let infoHeight;
338343

@@ -367,7 +372,7 @@ export default class MImageBody extends React.Component<IProps, IState> {
367372
}
368373

369374
// The maximum height of the thumbnail as it is rendered as an <img>
370-
const maxHeight = Math.min(this.props.maxImageHeight || 600, infoHeight);
375+
const maxHeight = forcedHeight || Math.min((this.props.maxImageHeight || 600), infoHeight);
371376
// The maximum width of the thumbnail, as dictated by its natural
372377
// maximum height.
373378
const maxWidth = infoWidth * maxHeight / infoHeight;
@@ -407,9 +412,9 @@ export default class MImageBody extends React.Component<IProps, IState> {
407412
}
408413

409414
const thumbnail = (
410-
<div className="mx_MImageBody_thumbnail_container" style={{ maxHeight: maxHeight + "px" }} >
415+
<div className="mx_MImageBody_thumbnail_container" style={{ maxHeight: maxHeight + "px", maxWidth: maxWidth + "px" }} >
411416
{ /* Calculate aspect ratio, using %padding will size _container correctly */ }
412-
<div style={{ paddingBottom: (100 * infoHeight / infoWidth) + '%' }} />
417+
<div style={{ paddingBottom: forcedHeight ? (forcedHeight + "px") : ((100 * infoHeight / infoWidth) + '%') }} />
413418
{ showPlaceholder &&
414419
<div className="mx_MImageBody_thumbnail" style={{
415420
// Constrain width here so that spinner appears central to the loaded thumbnail

src/components/views/messages/MImageReplyBody.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@ export default class MImageReplyBody extends MImageBody {
4242
const content = this.props.mxEvent.getContent<IMediaEventContent>();
4343

4444
const contentUrl = this.getContentUrl();
45-
const thumbnail = this.messageContent(contentUrl, this.getThumbUrl(), content);
45+
const thumbnail = this.messageContent(contentUrl, this.getThumbUrl(), content, 44);
4646
const fileBody = this.getFileBody();
4747
const sender = <SenderProfile
4848
mxEvent={this.props.mxEvent}
4949
enableFlair={false}
5050
/>;
5151

5252
return <div className="mx_MImageReplyBody">
53-
<div className="mx_MImageReplyBody_thumbnail">{ thumbnail }</div>
54-
<div className="mx_MImageReplyBody_sender">{ sender }</div>
55-
<div className="mx_MImageReplyBody_filename">{ fileBody }</div>
53+
{ thumbnail }
54+
<div className="mx_MImageReplyBody_info">
55+
<div className="mx_MImageReplyBody_sender">{ sender }</div>
56+
<div className="mx_MImageReplyBody_filename">{ fileBody }</div>
57+
</div>
5658
</div>;
5759
}
5860
}

0 commit comments

Comments
 (0)