Skip to content

Conversation

@Buer-Nahida
Copy link

Description

When viewing messages, thumbnails are loaded first, if loading fails, the original image is loaded as a fallback.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@github-actions
Copy link

github-actions bot commented Aug 17, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Buer-Nahida
Copy link
Author

🤔 Maybe let users control the max pixels of width and height of thumbnail is a better idea?

@Buer-Nahida
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

ajbura added a commit to cinnyapp/cla that referenced this pull request Aug 17, 2025
@Buer-Nahida Buer-Nahida changed the title Load Thumbnail first and fall back to the original image if it cannot be loaded (#2444) Load Thumbnail first and fall back to the original image if it cannot be loaded Aug 17, 2025
… image

When viewing messages, thumbnails are loaded first, if loading fails,
the original image is loaded as a fallback.
Copy link

@CyanChanges CyanChanges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +99 to +105
const decrypt = (encBuf: ArrayBuffer) => decryptFile(encBuf, mimeType ?? FALLBACK_MIMETYPE, encInfo);
let fileContent;
try {
fileContent = await downloadEncryptedMedia(mediaUrl, decrypt);
} catch {
fileContent = await downloadEncryptedMedia(mxcUrlToHttp(mx, url, useAuthentication) ?? url, decrypt);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should always use the original url for encrypted image as it is always going to fail to generate thumbnail for it.

Comment on lines +116 to +122
if (useThumbnail) {
setUseThumbnail(false);
loadSrc();
} else {
setLoad(false);
setError(true);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any particular reason to use this fallback strategy?

>
{renderViewer({
src: srcState.data,
src: useThumbnail ? (mxcUrlToHttp(mx, url, useAuthentication) ?? url) : srcState.data,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since encrypted message always going to use full image we should use srcState.data for them and url for normal images.

}

if (msgType === MsgType.Image) {
const content: IImageContent = getContent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IImageContent already provide the thumbnail image along with dimensions, should not we be passing that to ImageContent component?

resizeMethod: string
} | undefined;
if (width && height) {
const scale = (width > height ? width : height) / 800;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already has a standard thumbnail scaling function getThumbnailDimensions which is used to generate the thumbnail while sending images.

url?: string;
info?: IImageInfo & IThumbnailContent;
file?: IEncryptedFile;
info?: { h: number, w: number };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info is already described at line 50.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants