You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-05 23:10:41 +03:00
Add more comments to explain thumbnail sizing
This commit is contained in:
@@ -28,6 +28,10 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mx_MImageBody_thumbnail_container {
|
.mx_MImageBody_thumbnail_container {
|
||||||
|
// Prevent the padding-bottom (added inline in MImageBody.js) from
|
||||||
|
// effecting elements below the container.
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
// Make sure the _thumbnail is positioned relative to the _container
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,10 @@ export default class extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_messageContent(contentUrl, thumbUrl, content) {
|
_messageContent(contentUrl, thumbUrl, content) {
|
||||||
|
// The maximum height of the thumbnail as it is rendered as an <img>
|
||||||
const maxHeight = Math.min(THUMBNAIL_MAX_HEIGHT, content.info.h);
|
const maxHeight = Math.min(THUMBNAIL_MAX_HEIGHT, content.info.h);
|
||||||
|
// The maximum width of the thumbnail, as dictated by it's natural
|
||||||
|
// maximum height.
|
||||||
const maxWidth = content.info.w * maxHeight / content.info.h;
|
const maxWidth = content.info.w * maxHeight / content.info.h;
|
||||||
|
|
||||||
let img = null;
|
let img = null;
|
||||||
@@ -246,6 +249,8 @@ export default class extends React.Component {
|
|||||||
}} />
|
}} />
|
||||||
</div>;
|
</div>;
|
||||||
} else if (thumbUrl && !this.state.imgError) {
|
} else if (thumbUrl && !this.state.imgError) {
|
||||||
|
// Restrict the width of the thumbnail here, otherwise it will fill the container
|
||||||
|
// which has the same width as the timeline
|
||||||
img = <img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image"
|
img = <img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image"
|
||||||
style={{ "max-width": maxWidth + "px" }}
|
style={{ "max-width": maxWidth + "px" }}
|
||||||
alt={content.body}
|
alt={content.body}
|
||||||
|
|||||||
Reference in New Issue
Block a user