Merge pull request #6589 from matrix-org/dbkr/upscale_thumbnails
Upscale thumbnails to the container size
This commit is contained in:
commit
d7cb855419
1 changed files with 15 additions and 3 deletions
|
@ -347,12 +347,21 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
className="mx_MImageBody_thumbnail"
|
className="mx_MImageBody_thumbnail"
|
||||||
src={thumbUrl}
|
src={thumbUrl}
|
||||||
ref={this.image}
|
ref={this.image}
|
||||||
style={{ maxWidth: `min(100%, ${maxWidth}px)` }}
|
// Force the image to be the full size of the container, even if the
|
||||||
|
// pixel size is smaller. The problem here is that we don't know what
|
||||||
|
// thumbnail size the HS is going to give us, but we have to commit to
|
||||||
|
// a container size immediately and not change it when the image loads
|
||||||
|
// or we'll get a scroll jump (or have to leave blank space).
|
||||||
|
// This will obviously result in an upscaled image which will be a bit
|
||||||
|
// blurry. The best fix would be for the HS to advertise what size thumbnails
|
||||||
|
// it guarantees to produce.
|
||||||
|
style={{ height: '100%' }}
|
||||||
alt={content.body}
|
alt={content.body}
|
||||||
onError={this.onImageError}
|
onError={this.onImageError}
|
||||||
onLoad={this.onImageLoad}
|
onLoad={this.onImageLoad}
|
||||||
onMouseEnter={this.onImageEnter}
|
onMouseEnter={this.onImageEnter}
|
||||||
onMouseLeave={this.onImageLeave} />
|
onMouseLeave={this.onImageLeave}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +388,10 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div style={{ display: !showPlaceholder ? undefined : 'none' }}>
|
<div style={{
|
||||||
|
display: !showPlaceholder ? undefined : 'none',
|
||||||
|
height: '100%', // Also force to size of a parent to prevent scroll-jumps (see above)
|
||||||
|
}}>
|
||||||
{ img }
|
{ img }
|
||||||
{ gifLabel }
|
{ gifLabel }
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue