diff --git a/src/components/views/rooms/LinkPreviewGroup.tsx b/src/components/views/rooms/LinkPreviewGroup.tsx index 6cd2ce8db8..9f830fffe2 100644 --- a/src/components/views/rooms/LinkPreviewGroup.tsx +++ b/src/components/views/rooms/LinkPreviewGroup.tsx @@ -97,7 +97,12 @@ const fetchPreviews = (cli: MatrixClient, links: string[], ts: number): Promise< links.map(async (link): Promise<[string, IPreviewUrlResponse] | undefined> => { try { const preview = await cli.getUrlPreview(link, ts); - if (preview && Object.keys(preview).length > 0) { + // Ensure at least one of the rendered fields is truthy + if ( + preview?.["og:image"]?.startsWith("mxc://") || + !!preview?.["og:description"] || + !!preview?.["og:title"] + ) { return [link, preview]; } } catch (error) { diff --git a/src/components/views/rooms/LinkPreviewWidget.tsx b/src/components/views/rooms/LinkPreviewWidget.tsx index 88d83e4cf6..5684d9b6fd 100644 --- a/src/components/views/rooms/LinkPreviewWidget.tsx +++ b/src/components/views/rooms/LinkPreviewWidget.tsx @@ -75,9 +75,6 @@ export default class LinkPreviewWidget extends React.Component { public render(): React.ReactNode { const p = this.props.preview; - if (!p || Object.keys(p).length === 0) { - return
; - } // FIXME: do we want to factor out all image displaying between this and MImageBody - especially for lightboxing? let image: string | null = p["og:image"] ?? null;