diff --git a/app/components/ChatBox.js b/app/components/ChatBox.js
index f17b242..4bdc3d5 100644
--- a/app/components/ChatBox.js
+++ b/app/components/ChatBox.js
@@ -41,6 +41,19 @@ function getYoutubeId(url) {
return ID;
}
+function isImage(text) {
+ return text.indexOf("http") >= 0 && (text.indexOf('.jpg') || text.indexOf('.gif'));
+}
+
+// TODO: this needs to be reviewed. best to return as a css background-image instead
+function displayImage(text) {
+
+ let reg = new RegExp(/\b(https?:\/\/\S+(?:png|jpe?g|gif)\S*)\b/);
+ let imageUrl = reg.exec(text);
+ if (!imageUrl) return ();
+ return ()
+}
+
// TODO use regex for code parsing / detection. Add new line detection for shift+enter
const MessageRender = ({ message }) => {
const emojis = [];
@@ -115,6 +128,7 @@ class ChatBox extends PureComponent {
}
{!!imgUrl && }
+ {isImage(message) && displayImage(message)}
);
};