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
var imageLink = createElem2({
appendTo: messageTargetElem,
type:"a",
href: message.image_path,
});
//Image element if (messageFile.type == "image/png") {
createElem2({ var imageLink = createElem2({
appendTo: imageLink, appendTo: messageTargetElem,
type: "img", type: "a",
src: message.image_path, href: messageFile.url
class: "conversation-msg-image"
});
//Enable lightbox
imageLink.onclick = function(){
$(this).ekkoLightbox({
alwaysShowClose: true,
}); });
return false;
//Apply image
createElem2({
appendTo: imageLink,
type: "img",
class: "message-img",
src: messageFile.thumbnail == null ? messageFile.url : messageFile.thumbnail
});
imageLink.onclick = function(){
$(this).ekkoLightbox({
alwaysShowClose: true,
});
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"
} }
} }