Support all files types in chat box

This commit is contained in:
Pierre HUBERT 2021-03-06 15:09:36 +01:00
parent 5c6276d11a
commit 82a6dcb65b

View File

@ -916,29 +916,49 @@ const ConvChatWindow = {
}); });
//Check if an image has to be added //Check if an image has to be added
if(message.image_path != null){ if(message.file != null){
const messageFile = message.file;
//Image link if (messageFile.type == "image/png") {
var imageLink = createElem2({ var imageLink = createElem2({
appendTo: messageTargetElem, appendTo: messageTargetElem,
type: "a", type: "a",
href: message.image_path, href: messageFile.url
}); });
//Image element //Apply image
createElem2({ createElem2({
appendTo: imageLink, appendTo: imageLink,
type: "img", type: "img",
src: message.image_path, class: "message-img",
class: "conversation-msg-image" src: messageFile.thumbnail == null ? messageFile.url : messageFile.thumbnail
}); });
//Enable lightbox
imageLink.onclick = function(){ imageLink.onclick = function(){
$(this).ekkoLightbox({ $(this).ekkoLightbox({
alwaysShowClose: true, alwaysShowClose: true,
}); });
return false; return false;
};
}
else if(messageFile.type == "audio/mpeg") {
new SmallMediaPlayer(messageTargetElem, messageFile.url, false)
}
else if(messageFile.type == "video/mp4") {
new SmallMediaPlayer(messageTargetElem, messageFile.url, true)
}
// Fallback
else {
let letFileLink = createElem2({
appendTo: messageTargetElem,
type: "a",
href: messageFile.url,
innerHTML: "<i class='fa fa-download'></i> "+ messageFile.name + " (" + messageFile.size/1024 + "MB)",
})
letFileLink.target = "_blank"
} }
} }