In onebox, how to display random descriptions

The default Onebox takes description as the first paragraph in the original article, I want to describe it as random (get a random paragraph in the original article)

For example:

I do not want to describe in the default onebox as:

image

, I want each time to put the link into the markdown, the description will display randomly

Thank you very much

1 Like

Onebox doesn’t take the first paragraph. It takes a special description that is defined by the website owner for people who embed their sites.

In this example CNN defined what the description should be using a special tag in their website. We follow the specification.

4 Likes

The description cannot be displayed randomly as you are looking to have done. That would require searching the article for random text - something that is not feasible. If you search for Onebox requirements, you will see the three required things necessary for a website to give in order for the article to be Oneboxed. A text search within an article is not one of them and it not possible.
Edit: Falco posted a few seconds ahead of me. :slightly_smiling_face:

1 Like

Thanks, so is there a way to edit the code, help adjust onebox to get a random snippet in the original article, forming a description?

Thanks!

See Falco’s 2nd sentence above. It’s defined by the website owner to decide what will be seen when their link is embedded. There is nothing Discourse can do about that. Sorry.

1 Like

I would be very grateful if I could find a solution to edit the code for the problem of randomly displaying the description

Thanks Jimpas

1 Like

If you are a developer, you can look into overwriting the onebox behavior in a custom plugin.

1 Like

But there isn’t any code to edit. The website owner creates a tag with the description that is used for the embedded link. That is what Discourse uses to Onebox the link. There are no other descriptions (random or otherwise) that exist for Onebox to retrieve and use. Please see Rich link previews with Onebox

1 Like

Thank Falco

Yes, I am a developer
Can suggest me a Plugin, to make this adjustment.

You can guide me thinking of the steps to take, to achieve the random display goal described in Onebox.

Thanks !

1 Like

You can follow the example of this plugin here https://github.com/discourse/discourse/blob/master/plugins/lazy-yt/plugin.rb

2 Likes

Thank you
Falco is proposing a solution using the Custom Plugin, perhaps this will be a solution for me to develop. I still hope my goal is to display random descriptions in onebox, which are workable.

1 Like

If Falco could give more detailed instructions, during the nCov epidemic season, it would be the most meaningful gift I received.
If Falco is busy, I can also do my own research. In the process of implementing this problem, if there is a problem, I hope to be able to inbox you.
Thanks Falco.