mastodon-ios
mastodon-ios copied to clipboard
Proposal: Preview to message links.
Propose new feature: In case a message contains a link to a website, show preview of that website.
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
I can attempt to help with this feature if someone can point me in the right direction
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.
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.
Great I'll give this a shot and see how far I get.
@echan00 Are there any updates on this, how far have you come? I can offer my help and also give it a try.
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!
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.
I've got the beginnings of a UI for it, if the data is already there that would be amazing
You could alternatively use an LPLinkView, although I’m not sure if that would fit with the design of the rest of the app
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:
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.
Just as a note, are social cards / social previews known? Starting point might be https://socialsharepreview.com/
@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 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 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 ;)
Awesome, got the card persisting! Should be able to finish wiring things up pretty easily now