matrix-art

An image gallery for Matrix
git clone git://archive.git.mtrnord.blog/MTRNord/matrix-art.git
Log | Files | Refs | README | LICENSE

commit b57ea9ef11c69d31f50e3dd0f5d1c7a009f29a39
parent 981d67b150afca02556354b510c28e9b75377b9f
Author: MTRNord <mtrnord1@gmail.com>
Date:   Fri, 14 Jan 2022 14:58:20 +0100

Add image size to metadata

Diffstat:
Mpages/index.tsx | 8++++++--
Mpages/post/[id].tsx | 10+++++++---
2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/pages/index.tsx b/pages/index.tsx @@ -56,7 +56,9 @@ class Home extends PureComponent<Props, State>{ // TODO get this from the event itself "license": "https://creativecommons.org/licenses/by-nc-nd/4.0/", "author": event.content.displayname, - "name": image['m.text'] + "name": image['m.text'], + "width": image['m.image'].width, + "height": image['m.image'].height }; }); } else { @@ -76,7 +78,9 @@ class Home extends PureComponent<Props, State>{ // TODO get this from the event itself "license": "https://creativecommons.org/licenses/by-nc-nd/4.0/", "author": event.content.displayname, - "name": event.content['m.text'] + "name": event.content['m.text'], + "width": event.content['m.image'].width, + "height": event.content['m.image'].height }; } }); diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx @@ -254,7 +254,9 @@ class Post extends PureComponent<Props, State> { // TODO get this from the event itself license: "https://creativecommons.org/licenses/by-nc-nd/4.0/", author: this.state.displayname, - name: imageEvent.content['m.text'] + name: imageEvent.content['m.text'], + "width": imageEvent.content['m.image'].width, + "height": imageEvent.content['m.image'].height }; const blurhash = imageEvent.content['xyz.amorgan.blurhash']; const image_html = blurhash ? ( @@ -298,7 +300,7 @@ class Post extends PureComponent<Props, State> { } renderImageGalleryEvent(imageEvent: ImageGalleryEvent, caption: string) { - const metadata: { "@context": string; "@type": string; contentUrl: string; license: string; author: string; name: string; thumbnail: any; encodingFormat: string; }[] = []; + const metadata: { "@context": string; "@type": string; contentUrl: string; license: string; author: string; name: string; thumbnail: any; encodingFormat: string; width: number; height: number; }[] = []; const images = imageEvent.content['m.image_gallery'].map(image => { const url = this.context.client?.downloadLink(image["m.file"].url); const thumbnail_url = this.context.client?.downloadLink(image['m.thumbnail'][0].url); @@ -321,7 +323,9 @@ class Post extends PureComponent<Props, State> { // TODO get this from the event itself license: "https://creativecommons.org/licenses/by-nc-nd/4.0/", author: this.state.displayname!, - name: image['m.text'] + name: image['m.text'], + "width": image['m.image'].width, + "height": image['m.image'].height }); const blurhash = image["xyz.amorgan.blurhash"]; const image_html = blurhash ? (