hydrogen-web icon indicating copy to clipboard operation
hydrogen-web copied to clipboard

Thumbnails of images uploaded via API return invalid width

Open daedric7 opened this issue 2 years ago • 0 comments

Describe the bug I have several scripts downloading images from websites and posting them in a few rooms.

The image miniature is displayed correctly by Element.

Yet, hydrogen tries to use the dynamic thumbnail to generate the thumbnail, and fails with both width and height being NaN, resulting in:

{"errcode":"M_INVALID_PARAM","error":"Query parameter 'width' must be an integer"}

There are differences between a image uploaded via API and via Element:

API:

{
  "type": "m.room.message",
  "sender": "@dabot:aguiarvieira.pt",
  "content": {
    "body": "oj7lzggmp03b1.png",
    "msgtype": "m.image",
    "filename": "oj7lzggmp03b1.png",
    "url": "mxc://aguiarvieira.pt/PKYZYDmyTYeggoktiRTRMgtE"
  },
  "origin_server_ts": 1685473939679,
  "unsigned": {
    "age": 47
  },
  "event_id": "$9l9xn_wD3g7HgyrEtN-5YAAaNnlxtrYbADJGg2upQGA",
  "room_id": "!VlADlaAKzYXdFhLQhZ:aguiarvieira.pt"
}

Element:

{
  "type": "m.room.message",
  "sender": "@daedric:aguiarvieira.pt",
  "content": {
    "body": "png-transparent-penguin-tux-design-logo-linux-penguin-animals-logo-vertebrate.png",
    "info": {
      "size": 18070,
      "mimetype": "image/png",
      "w": 920,
      "h": 550,
      "xyz.amorgan.blurhash": "LKRfd[ad.TtSS6bHs,jsyEkCMwad"
    },
    "msgtype": "m.image",
    "url": "mxc://aguiarvieira.pt/gAasggirXwIdcCYjVyyUmsyp"
  },
  "origin_server_ts": 1685462095591,
  "unsigned": {
    "age": 103
  },
  "event_id": "$QHBYeJYqXbwmJ0Q7y7anXP3IaaA0s9AJtGOTZgs3i8Y",
  "room_id": "!BhYbDqbkGKjvDHvnTq:aguiarvieira.pt"
}

To Reproduce Steps to reproduce the behavior:

  1. Upload image via curl or any other tool that uses the Matrix API
  2. Open respective room
  3. Notice absense of thumbnail
  4. Confirm that clicking the missing thumbnail/link opens the original image

Expected behavior Thumbnails for images without extra info should attempt to use a width proportional to screen, or a static value.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows
  • Chrome
  • Latest

Smartphone (please complete the following information):

  • Device: OP7
  • OS: Android 13
  • Browser Chrome
  • Version latest

Additional context

Ex. URL : https://aguiarvieira.pt/_matrix/media/r0/thumbnail/aguiarvieira.pt/cRiTRpNSpfBbniXepLFzWKxt?width=NaN&height=NaN&method=scale

daedric7 avatar May 30 '23 20:05 daedric7