diff --git a/src/domain/session/room/timeline/MessageBody.js b/src/domain/session/room/timeline/MessageBody.js index d232c021..325c79e1 100644 --- a/src/domain/session/room/timeline/MessageBody.js +++ b/src/domain/session/room/timeline/MessageBody.js @@ -81,9 +81,12 @@ export class FormatPart { } export class ImagePart { - constructor(src, properties) { + constructor(src, width, height, alt, title) { this.src = src; - this.properties = properties; + this.width = width; + this.height = height; + this.alt = alt; + this.title = title; } get type() { return "image"; } diff --git a/src/domain/session/room/timeline/deserialize.js b/src/domain/session/room/timeline/deserialize.js index 6c720cbc..480117eb 100644 --- a/src/domain/session/room/timeline/deserialize.js +++ b/src/domain/session/room/timeline/deserialize.js @@ -73,11 +73,11 @@ class Deserializer { if (!url) { return null; } - const width = result.getAttributeValue(node, "width"); - const height = result.getAttributeValue(node, "height"); + const width = parseInt(result.getAttributeValue(node, "width")) || null; + const height = parseInt(result.getAttributeValue(node, "height")) || null; const alt = result.getAttributeValue(node, "alt"); const title = result.getAttributeValue(node, "title"); - return new ImagePart(url, { width, height, alt, title }); + return new ImagePart(url, width, height, alt, title); } parseElement(node) { diff --git a/src/platform/web/ui/session/room/timeline/TextMessageView.js b/src/platform/web/ui/session/room/timeline/TextMessageView.js index a6cc5bec..e244ab3a 100644 --- a/src/platform/web/ui/session/room/timeline/TextMessageView.js +++ b/src/platform/web/ui/session/room/timeline/TextMessageView.js @@ -43,13 +43,12 @@ function renderList(listBlock) { } function renderImage(imagePart) { - const props = imagePart.properties; const attributes = Object.assign( { src: imagePart.src }, - props.width && { width: props.width }, - props.height && { height: props.height }, - props.alt && { alt: props.alt }, - props.title && { title: props.title } + imagePart.width && { width: imagePart.width }, + imagePart.height && { height: imagePart.height }, + imagePart.alt && { alt: imagePart.alt }, + imagePart.title && { title: imagePart.title } ); return tag.img(attributes, []); }