默认的 Onebox 将原文的第一段作为描述,我希望将其描述为随机的(从原文中随机获取一段)。
例如:
我不希望默认的 Onebox 显示如下描述:
我希望每次将链接放入 Markdown 时,描述都能随机显示。
非常感谢。
默认的 Onebox 将原文的第一段作为描述,我希望将其描述为随机的(从原文中随机获取一段)。
例如:
我不希望默认的 Onebox 显示如下描述:
我希望每次将链接放入 Markdown 时,描述都能随机显示。
非常感谢。
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.
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. 
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.
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
If you are a developer, you can look into overwriting the onebox behavior in a custom plugin.
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
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 !
You can follow the example of this plugin here https://github.com/discourse/discourse/blob/master/plugins/lazy-yt/plugin.rb
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.
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.