Search code examples
vue.jsnuxt.jsreddit

Reddit image retrieval from url


An url was postet at reddit: https://www.reddit.com/r/harrypotter/comments/apwv4v/rawenclaw_or_hufflepuff/

But reddit was not able to retrieve an image from the website and is showing a default image.

How do you tell websites like reddit which image to show there? And how can you set this image in a nuxt vue file?


Solution

  • Reddit (and most of the other major sites that do this, like Facebook and Twitter) uses the og:url Open Graph tag, if present.

    Full details of Open Graph can be found at http://ogp.me/, but fundamentally:

    <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
    

    If an og:image is not present, most sites will try to guess which image on the page is the right one. They'll often get it wrong.