Reputation: 12341
I was looking at how Facebook makes external websites previews given on a URL shared by the user. The result is not just a thumbnail but actual text, an embedded video or an image depending on the link given. For example, if you post a link from a Wikipedia article, it displays text. If you post the link of a video from Dailymotion, it embeds it. Is there a PHP/Javascript-Ajax approach to accomplish this? Any specific library for this purpose?
If there isn't, what's the best way server-side (in PHP if possible) solution for web scraping and displaying a thumbnail preview?
Upvotes: 0
Views: 382
Reputation: 180014
Facebook does this by looking for Open Graph meta tags. In the case of embedded videos, it's looking for the og:video
tag.
If there aren't OG tags, it'll make a best guess.
Upvotes: 2