From 5fb860caca7d615ec8f1a8f4b063525e4d9e786f Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sun, 5 Nov 2017 06:09:05 +0000 Subject: [PATCH] Embed attached images --- webapp/titanembeds/static/css/embedstyle.css | 5 +++++ webapp/titanembeds/static/js/embed.js | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/webapp/titanembeds/static/css/embedstyle.css b/webapp/titanembeds/static/css/embedstyle.css index 5b94ca8..766089c 100644 --- a/webapp/titanembeds/static/css/embedstyle.css +++ b/webapp/titanembeds/static/css/embedstyle.css @@ -584,6 +584,11 @@ p.mentioned span.chatmessage { width: 100%; } +#chatcontent img.attachment { + width: 100%; + max-width: 300px; +} + #emoji-picker { color: black; position: fixed; diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index c8d30e6..2d0dffc 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -736,7 +736,11 @@ if (message.content.length != 0) { attach = " "; } - attach += message.attachments[i].url; + if (message.attachments[i].url.endsWith(".png") || message.attachments[i].url.endsWith(".jpg") || message.attachments[i].url.endsWith(".jpeg") || message.attachments[i].url.endsWith(".gif")) { + attach += ""; + } else { + attach += message.attachments[i].url; + } message.content += attach; } return message; @@ -900,10 +904,10 @@ message = replace_message_mentions(message); message = format_bot_message(message); message = parse_message_time(message); - message = parse_message_attachments(message); message.content = message.content.replaceAll("\\<", "<"); message.content = message.content.replaceAll("\\>", ">"); message.content = escapeHtml(message.content); + message = parse_message_attachments(message); message.content = parse_message_markdown(message.content); message = parse_channels_in_message(message); message = parse_emoji_in_message(message);