Add more comments to explain thumbnail sizing
This commit is contained in:
parent
d11442de04
commit
7e7e2a7473
2 changed files with 9 additions and 0 deletions
|
@ -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}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue