mastodon-ios icon indicating copy to clipboard operation
mastodon-ios copied to clipboard

Proposal: Preview to message links.

Open ghost opened this issue 2 years ago • 17 comments

Propose new feature: In case a message contains a link to a website, show preview of that website.

ghost avatar Jul 31 '21 18:07 ghost

Are you referring to showing the Open Graph data? A preview of the link including the text, image/video, etc?

It would be great to show preview/embed of youtube videos

echan00 avatar Oct 03 '21 15:10 echan00

I can attempt to help with this feature if someone can point me in the right direction

echan00 avatar Oct 03 '21 17:10 echan00

I can attempt to help with this feature if someone can point me in the right direction

Yes, basically we could use Open Graph parser or UI components likes:

  • https://github.com/zadr/OG
  • https://github.com/marty-suzuki/URLEmbeddedView

We using AutoLayout with UIStackView. So just add a custom subclass about preview into the container. Set the UI hidden when content does not contain any URL. Set not hidden if it contains one. I'm not sure should we display all URLs or just first. But all URLs we could get from MetaContent.

You can check StatusView.swift for more details. And please make a PR and I can give you help for your needs.

MainasuK avatar Oct 04 '21 00:10 MainasuK

It would be great to show preview/embed of youtube videos

I'm not sure if that is a good direction. I just finger out inline video is a lit bit complex than a modal preview. But that's possible if we could obtain the video asset URL.

MainasuK avatar Oct 04 '21 00:10 MainasuK

Great I'll give this a shot and see how far I get.

echan00 avatar Oct 05 '21 03:10 echan00

@echan00 Are there any updates on this, how far have you come? I can offer my help and also give it a try.

vollkorntomate avatar May 10 '22 09:05 vollkorntomate

Yes, basically we could use Open Graph parser or UI components likes:

I think there is some misunderstanding here because the Mastodon server already does the Open Graph / OEmbed parsing for the link and provides the results in the API. The app just needs to render it - possibly the most complicated part being rendering the iframe of e.g. a YouTube video. Fetching OpenGraph data live in the app while the user is browsing would not be a good idea!

Gargron avatar May 10 '22 09:05 Gargron

the Mastodon server already does the Open Graph / OEmbed parsing for the link and provides the results in the API

@Gargron is that implemented in the API on iOS? I'm not seeing anything other than the URL in the MetaContent, and I don't see where that info would be in the Status model either.

kylebshr avatar Nov 12 '22 02:11 kylebshr

I've got the beginnings of a UI for it, if the data is already there that would be amazing Simulator Screen Shot - iPhone 14 Pro - 2022-11-11 at 18 36 16

kylebshr avatar Nov 12 '22 02:11 kylebshr

You could alternatively use an LPLinkView, although I’m not sure if that would fit with the design of the rest of the app

j-f1 avatar Nov 12 '22 03:11 j-f1

I think a custom design works better, but good call on the LinkPresentation framework. If the OG data isn't in the API we can use that - I have it working, here's an example: Simulator Screen Shot - iPhone 14 Pro - 2022-11-12 at 11 24 34

kylebshr avatar Nov 12 '22 19:11 kylebshr

Hi there, small media startup member here: It would be extremely great, if the image for the link preview would be much bigger. This is the case on all major networks like Facebook and Twitter, because more people click on links if you can already show them interesting content in the preview image. To make Mastodon an interesting platform for news websites and journalists this would be very much appreciated by everyone I think.

pkreissel avatar Nov 21 '22 17:11 pkreissel

Just as a note, are social cards / social previews known? Starting point might be https://socialsharepreview.com/

SchulteMarkus avatar Nov 22 '22 19:11 SchulteMarkus

@kylebshr The Status object from Mastodon has a card field which is of type PreviewCard. Would you be interested in wiring that up to your UI?

(it would also be neat if an embedded web view could be used to make videos playable inline)

j-f1 avatar Nov 22 '22 21:11 j-f1

@j-f1 that sounds perfect, but it looks like the card field isn't being parsed and stored currently; is that something you could help with?

kylebshr avatar Nov 24 '22 02:11 kylebshr

@kylebshr there are some recently added docs on changing the model objects at https://github.com/mastodon/mastodon-ios/blob/develop/Documentation/How-it-works.md but so far I’ve managed to avoid having to try it myself ;)

j-f1 avatar Nov 24 '22 03:11 j-f1

Awesome, got the card persisting! Should be able to finish wiring things up pretty easily now

kylebshr avatar Nov 24 '22 04:11 kylebshr