diff --git a/pkg/interface/src/views/components/RemoteContent.tsx b/pkg/interface/src/views/components/RemoteContent.tsx index 630172cd4a..af26d032b1 100644 --- a/pkg/interface/src/views/components/RemoteContent.tsx +++ b/pkg/interface/src/views/components/RemoteContent.tsx @@ -23,6 +23,7 @@ interface RemoteContentProps { interface RemoteContentState { unfold: boolean; embed: any | undefined; + noCors: boolean; } const IMAGE_REGEX = new RegExp(/(jpg|img|png|gif|tiff|jpeg|webp|webm|svg)$/i); @@ -36,11 +37,13 @@ class RemoteContent extends PureComponent); } + onError(e: Event) { + this.setState({ noCors: true }); + } + render() { const { remoteContentPolicy, @@ -103,6 +110,7 @@ return; onLoad = () => {}, ...props } = this.props; + const { noCors } = this.state; const isImage = IMAGE_REGEX.test(url); const isAudio = AUDIO_REGEX.test(url); const isVideo = VIDEO_REGEX.test(url); @@ -111,11 +119,12 @@ return; if (isImage && remoteContentPolicy.imageShown) { return this.wrapInLink(