Search code examples
javascripthtmlimagehyperlinkreddit

Show image in reddit post from link


On my website, I want it to be so when users post on reddit using a link to link to my page, an image is displayed that when clicked goes to the page. Here is an example: https://www.reddit.com/r/memes/comments/cfeewv/when_you_really_think_about_it/

it links to imgur. Does anyone know how to set the image on the site or make the link like that? I am asking this on stackoverflow because I assume that in order to set the link to a certain image or tag, it requires some change in the formatting of the code.


Solution

  • All you need on your site is a meta tag which will contain the link to the image you'll like to display.

    <meta property="og:image" content="http://euro-travel-example.com/thumbnail.jpg">
    

    This is the same with WhatsApp when you share a link. They extract this same image from the site. Here's a blog post for you