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
if(message.image_path != null){
if(message.file != null){
const messageFile = message.file;
//Image link
if (messageFile.type == "image/png") {
var imageLink = createElem2({
appendTo: messageTargetElem,
type: "a",
href: message.image_path,
href: messageFile.url
});
//Image element
//Apply image
createElem2({
appendTo: imageLink,
type: "img",
src: message.image_path,
class: "conversation-msg-image"
class: "message-img",
src: messageFile.thumbnail == null ? messageFile.url : messageFile.thumbnail
});
//Enable lightbox
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"
}
}