Reputation: 11523
When you share a link on Facebook, it displays an image from that webpage. How can I add that functionality to a forum I have?. I use django (but I am not sure if this matters).
Upvotes: 1
Views: 89
Reputation: 1463
There is an API called thumbalizr. https://api.thumbalizr.com/
It's quite simple to use, you give it the URL and the width of the img. It gets you the thumbnail.
I bet there's many similar tools, but this seems to be one of the most popular.
EDIT:
https://api.thumbalizr.com/?url=URL_HERE
Upvotes: 1
Reputation: 5261
Here's a good article explaining a sample algorithm for finding the "best" image to represent an external webpage. It checks for the OG (Open Graph) tags that @petkostas mentioned, if the external page happens to use them. Otherwise, it looks for images on its own.
https://tech.shareaholic.com/2012/11/02/how-to-find-the-image-that-best-respresents-a-web-page/
Upvotes: 3
Reputation: 7450
Facebook uses OG for sharing, use the image tag of OG in your template. https://developers.facebook.com/docs/opengraph/howtos/maximizing-distribution-media-content Use an empty block in your template:
{% block opengraph %}{% endblock opengraph %}
Upvotes: 0