MM-26946 Handle invalid YouTube links (#4571)
* Handle invalid YouTube links * Fallback to default thumbnail
This commit is contained in:
parent
0ad62ced40
commit
cf8a67a7a5
1 changed files with 10 additions and 1 deletions
|
|
@ -391,7 +391,16 @@ export default class PostBodyAdditionalContent extends ImageViewPort {
|
|||
getViewPortWidth(this.props.isReplyPost, this.hasPermanentSidebar()),
|
||||
);
|
||||
|
||||
const imgUrl = Object.keys(this.props.metadata.images)[0] || `https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`;
|
||||
let imgUrl;
|
||||
if (this.props.metadata?.images) {
|
||||
imgUrl = Object.keys(this.props.metadata.images)[0];
|
||||
}
|
||||
|
||||
if (!imgUrl) {
|
||||
// Fallback to default YouTube thumbnail if available
|
||||
imgUrl = `https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`;
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableWithFeedback
|
||||
style={[styles.imageContainer, {height: dimensions.height}]}
|
||||
|
|
|
|||
Loading…
Reference in a new issue