jwr1 / interstellar

An app for Mbin and Lemmy, connecting you to the fediverse.
https://kbin.earth/m/interstellar
GNU General Public License v3.0
41 stars 5 forks source link

Posts from Lemmy that link to pictures on imgur don't display an image #62

Closed evanfoster closed 1 week ago

evanfoster commented 2 weeks ago

Describe the bug

Hey there!

When looking at a post from Lemmy that links to an image on imgur, the image is not displayed in the app. Additionally, the source is not displayed, so you must instead tap on the three dot menu, click "Open in Browser", and then click on the link. Here's a screenshot of one such post:

Screenshot_20240922-114722

Here's a link to that post: https://kbin.earth/m/pics@lemmy.world/t/347481

Steps to Reproduce

  1. Go to a Lemmy post that links to an image on imgur. For example, find this post: https://kbin.earth/m/pics@lemmy.world/t/347481
  2. Click on said post
  3. The image will not be visible without viewing the post through the browser on mbin.

Version

0.6.0

What platform(s) are you seeing the problem on?

Android

Additional context

I'm guessing this is probably caused by imgur's hostility to image hot links. I seem to recall hearing that imgur requires the use of a paid API in order to hotlink to images, although I don't know if that's actually true. Assuming it is, I don't know what the best solution would be. The quick-and-dirty one is to add another check here.

      url: (lemmyPost['url_content_type'] != null &&
              (lemmyPost['url_content_type'] as String).startsWith('image/'))
          ? null
          : lemmyPost['url'] as String?,

Like, if the image is from imgur, then you could display the source. That'd make it much easier to quickly see the image.

evanfoster commented 2 weeks ago

Based on what I'm seeing in post.dart, I've made this issue specific to imgur posts coming from Lemmy. This might still be an issue with mbin posts, but the difference in how the post model is constructed in that case probably warrants a different issue.

jwr1 commented 2 weeks ago

I think this is an issue with Mbin. If you go to the API request for the post (here), you can see the type is set to image, but the image field is null, where it should be filled in with an ImageDTO. Either the type should be image and the image key is filled out, or the type should be link if it's just a link, which in this case, that's what it should be marked as.

The reason Interstellar isn't displaying the link is because of that type from the API response being set to image, but if necessary, I could change it so it instead checks if the image key is missing.

I'll ask on the Mbin matrix and see if they know anything.

jwr1 commented 1 week ago

This should be fixed in commit a5d2d5e1367875b7c280dc374a25e511d662f72e.

This way, a thread's link is still present if, for some reason, the thread is marked as an image but doesn't actually have an image attached to it.

image