PreviewCard
sometimes has width and height of 0 despite there being an image
#30032
Labels
PreviewCard
sometimes has width and height of 0 despite there being an image
#30032
Steps to reproduce the problem
PreviewCard
, such as https://mastodon.social/api/v1/statuses/112315527391062666Expected behaviour
If the preview card has an
image
, thewidth
andheight
attributes should match the width and height of the imageActual behaviour
Sometimes the preview card has an
image
with nonzero width and height, but thewidth
andheight
attributes of the preview card are0
Detailed description
When the API returns a
width
andheight
that do not match the actual dimensions of the image, it can cause layout problems for clients. In the web UI, this manifests as the rectangular image being mistakenly cropped to a square.For example, https://mastodon.social/@targetdrone/112315527391062666
In my own client app I’m simply discarding the image if the width or height is 0, because there’s no good way to predict what shape the image will be and I want to avoid awkward cropping or stretching. Of course, it would be better if the values were accurate so I could display the image.
Mastodon instance
mastodon.social, mastodon.online, mas.to all seem to have the issue for previews of this particular link
Mastodon version
seen on servers running v4.3.0-nightly.2024-04-18 and v4.2.8
Technical details
All links to “whentaken.com” appear to have the issue, but I’ve occasionally seen it with others as well.
Prettified response from the API mentioned above:
The text was updated successfully, but these errors were encountered: