Cadence Ember
4acd806e66
All checks were successful
continuous-integration/drone/push Build is passing
32 lines
715 B
JavaScript
32 lines
715 B
JavaScript
const {ejs, ElemJS} = require("../basic")
|
|
const {resolveMxc} = require("../functions")
|
|
const {MatrixEvent} = require("./event")
|
|
|
|
class Image extends MatrixEvent {
|
|
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]
|