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

Commit

Permalink
Save content.info as a local for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
jryans authored and dbkr committed May 15, 2019
1 parent 851d207 commit 3ea187a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/views/messages/MImageBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ export default class MImageBody extends React.Component {
// so we'll need to download the original image for this to work
// well for now. First, let's try a few cases that let us avoid
// downloading the original:
if (pixelRatio === 1.0 ||
(!content.info || !content.info.w ||
!content.info.h || !content.info.size)) {
const info = content.info;
if (
pixelRatio === 1.0 ||
(!info || !info.w || !info.h || !info.size)
) {
// always thumbnail. it may look a bit worse, but it'll save bandwidth.
// which is probably desirable on a lo-dpi device anyway.
return this.context.matrixClient.mxcUrlToHttp(content.url, thumbWidth, thumbHeight);
Expand All @@ -215,10 +217,10 @@ export default class MImageBody extends React.Component {
// timeline (e.g. >1MB).

const isLargerThanThumbnail = (
content.info.w > thumbWidth ||
content.info.h > thumbHeight
info.w > thumbWidth ||
info.h > thumbHeight
);
const isLargeFileSize = content.info.size > 1*1024*1024;
const isLargeFileSize = info.size > 1*1024*1024;

if (isLargeFileSize && isLargerThanThumbnail) {
// image is too large physically and bytewise to clutter our timeline so
Expand Down

0 comments on commit 3ea187a

Please sign in to comment.