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

Commit d7cb855

Browse files
authored
Merge pull request #6589 from matrix-org/dbkr/upscale_thumbnails
Upscale thumbnails to the container size
2 parents 87690f0 + 50aa3d6 commit d7cb855

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/components/views/messages/MImageBody.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,21 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
347347
className="mx_MImageBody_thumbnail"
348348
src={thumbUrl}
349349
ref={this.image}
350-
style={{ maxWidth: `min(100%, ${maxWidth}px)` }}
350+
// Force the image to be the full size of the container, even if the
351+
// pixel size is smaller. The problem here is that we don't know what
352+
// thumbnail size the HS is going to give us, but we have to commit to
353+
// a container size immediately and not change it when the image loads
354+
// or we'll get a scroll jump (or have to leave blank space).
355+
// This will obviously result in an upscaled image which will be a bit
356+
// blurry. The best fix would be for the HS to advertise what size thumbnails
357+
// it guarantees to produce.
358+
style={{ height: '100%' }}
351359
alt={content.body}
352360
onError={this.onImageError}
353361
onLoad={this.onImageLoad}
354362
onMouseEnter={this.onImageEnter}
355-
onMouseLeave={this.onImageLeave} />
363+
onMouseLeave={this.onImageLeave}
364+
/>
356365
);
357366
}
358367

@@ -379,7 +388,10 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
379388
</div>
380389
}
381390

382-
<div style={{ display: !showPlaceholder ? undefined : 'none' }}>
391+
<div style={{
392+
display: !showPlaceholder ? undefined : 'none',
393+
height: '100%', // Also force to size of a parent to prevent scroll-jumps (see above)
394+
}}>
383395
{ img }
384396
{ gifLabel }
385397
</div>

0 commit comments

Comments
 (0)