diff --git a/src/components/views/messages/MImageBody.js b/src/components/views/messages/MImageBody.js index c42840b03a..8ab3705766 100644 --- a/src/components/views/messages/MImageBody.js +++ b/src/components/views/messages/MImageBody.js @@ -185,7 +185,7 @@ export default class extends React.Component { const content = this.props.mxEvent.getContent(); if (content.file !== undefined && this.state.decryptedUrl === null) { let thumbnailPromise = Promise.resolve(null); - if (content.info.thumbnail_file) { + if (content.info && content.info.thumbnail_file) { thumbnailPromise = decryptFile( content.info.thumbnail_file, ).then(function(blob) { @@ -239,11 +239,20 @@ export default class extends React.Component { } _messageContent(contentUrl, thumbUrl, content) { + // If unspecifide in the thumbnail info, assume width x height to be 800 x 600. + let infoHeight = 600; + let infoWidth = 800; + + if (content.info && content.info.h && content.info.w) { + infoHeight = content.info.h; + infoWidth = content.info.w; + } + // The maximum height of the thumbnail as it is rendered as an - const maxHeight = Math.min(this.props.maxImageHeight || 600, content.info.h); + const maxHeight = Math.min(this.props.maxImageHeight || 600, infoHeight); // The maximum width of the thumbnail, as dictated by its natural // maximum height. - const maxWidth = content.info.w * maxHeight / content.info.h; + const maxWidth = infoWidth * maxHeight / infoHeight; let img = null; let placeholder = null; @@ -274,12 +283,12 @@ export default class extends React.Component { const thumbnail = (