2020-11-07 12:04:42 +00:00
|
|
|
const {ejs, ElemJS} = require("../basic")
|
|
|
|
const {resolveMxc} = require("../functions")
|
2020-11-26 13:48:30 +00:00
|
|
|
const {GroupableEvent} = require("./event")
|
2020-11-07 12:04:42 +00:00
|
|
|
|
2020-11-26 13:48:30 +00:00
|
|
|
class Image extends GroupableEvent {
|
2020-11-07 12:04:42 +00:00
|
|
|
render() {
|
|
|
|
this.clearChildren()
|
|
|
|
this.class("c-message--media")
|
|
|
|
const image = (
|
|
|
|
ejs("img")
|
|
|
|
.class("c-message__image")
|
|
|
|
.attribute("src", resolveMxc(this.data.content.url))
|
|
|
|
)
|
|
|
|
const info = this.data.content.info
|
|
|
|
if (info && info.w && info.h) {
|
|
|
|
image.attribute("width", info.w)
|
|
|
|
image.attribute("height", info.h)
|
|
|
|
}
|
|
|
|
this.child(image)
|
|
|
|
super.render()
|
|
|
|
}
|
|
|
|
|
|
|
|
static canRender(event) {
|
|
|
|
return event.type === "m.room.message" && event.content.msgtype === "m.image"
|
|
|
|
}
|
|
|
|
|
|
|
|
canGroup() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = [Image]
|