Url preview error handling improved, Tries to parse image height and width in case they are in string form
This commit is contained in:
parent
832a34020f
commit
13c4e14762
1 changed files with 6 additions and 6 deletions
|
@ -416,7 +416,7 @@ function Embed({ link }) {
|
||||||
return <YoutubeEmbed link={link} />;
|
return <YoutubeEmbed link={link} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [urlPreviewInfo, setUrlPreviewInfo] = useState({});
|
const [urlPreviewInfo, setUrlPreviewInfo] = useState();
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -435,15 +435,15 @@ function Embed({ link }) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (urlPreviewInfo !== undefined) {
|
if (urlPreviewInfo != null) {
|
||||||
// Image only embed
|
// Image only embed
|
||||||
if (urlPreviewInfo['og:image'] != null && urlPreviewInfo['og:image:width'] != null && urlPreviewInfo['og:image:height'] != null && urlPreviewInfo['og:title'] == null && urlPreviewInfo['og:description'] == null) {
|
if (urlPreviewInfo['og:image'] != null && urlPreviewInfo['og:image:width'] != null && urlPreviewInfo['og:image:height'] != null && urlPreviewInfo['og:title'] == null && urlPreviewInfo['og:description'] == null) {
|
||||||
return (
|
return (
|
||||||
<div className="file-container">
|
<div className="file-container">
|
||||||
<Image
|
<Image
|
||||||
link={mx.mxcUrlToHttp(urlPreviewInfo['og:image'])}
|
link={mx.mxcUrlToHttp(urlPreviewInfo['og:image'])}
|
||||||
height={urlPreviewInfo['og:image:height']}
|
height={parseInt(urlPreviewInfo['og:image:height'], 10)}
|
||||||
width={urlPreviewInfo['og:image:width']}
|
width={parseInt(urlPreviewInfo['og:image:width'], 10)}
|
||||||
name={urlPreviewInfo['og:image:alt'] || urlPreviewInfo['og:title'] || urlPreviewInfo['og:site_name'] || ''}
|
name={urlPreviewInfo['og:image:alt'] || urlPreviewInfo['og:title'] || urlPreviewInfo['og:site_name'] || ''}
|
||||||
type={urlPreviewInfo['og:image:type']}
|
type={urlPreviewInfo['og:image:type']}
|
||||||
/>
|
/>
|
||||||
|
@ -479,8 +479,8 @@ function Embed({ link }) {
|
||||||
{urlPreviewInfo['og:image'] != null && urlPreviewInfo['og:image:width'] != null && urlPreviewInfo['og:image:height'] != null && (
|
{urlPreviewInfo['og:image'] != null && urlPreviewInfo['og:image:width'] != null && urlPreviewInfo['og:image:height'] != null && (
|
||||||
<Image
|
<Image
|
||||||
link={mx.mxcUrlToHttp(urlPreviewInfo['og:image'])}
|
link={mx.mxcUrlToHttp(urlPreviewInfo['og:image'])}
|
||||||
height={urlPreviewInfo['og:image:height']}
|
height={parseInt(urlPreviewInfo['og:image:height'], 10)}
|
||||||
width={urlPreviewInfo['og:image:width']}
|
width={parseInt(urlPreviewInfo['og:image:width'], 10)}
|
||||||
name={urlPreviewInfo['og:image:alt'] || urlPreviewInfo['og:title'] || urlPreviewInfo['og:site_name'] || ''}
|
name={urlPreviewInfo['og:image:alt'] || urlPreviewInfo['og:title'] || urlPreviewInfo['og:site_name'] || ''}
|
||||||
type={urlPreviewInfo['og:image:type']}
|
type={urlPreviewInfo['og:image:type']}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue