chat-ui: fix image previews from url types

This commit is contained in:
Logan Allen 2019-10-24 14:31:40 -07:00
parent c8cca2f261
commit e06acb87be
2 changed files with 17 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -29,12 +29,27 @@ export class Message extends Component {
</span>
);
} else if ('url' in letter) {
let imgMatch =
/(jpg|img|png|gif|tiff|jpeg|JPG|IMG|PNG|TIFF|GIF|webp|WEBP|webm|WEBM)$/
.exec(letter.url);
let contents = letter.url;
if (imgMatch) {
contents = (
<img
src={letter.url}
style={{
width: "50%",
maxWidth: "250px"
}}
></img>
);
}
return (
<a className="body-regular-400 v-top"
href={letter.url}
target="_blank"
rel="noopener noreferrer">
{letter.url}
{contents}
</a>
);
} else if ('me' in letter) {