Exclude image from Open Graph

2019-09-06 13:16发布

问题:

tl;dr I'm wanting to specify NO image by default in my og:image tag.

I've been googling like a madman to figure this one out, but everything I find are questions from people who can't get their images to show up instead of preventing their images from showing up.

So, here's the deal. On my personal website in my master page is a picture of my face. Now, it's a nice picture (because, hey, it's a nice face) and I'd like to keep it, but I don't like that it's picked up by social media scrapers whenever my links are shared - that just seems a little too egotistical.

I DO like that it picks up other images, like the ones I occasionally include in my blog posts, but if there aren't any other images on a page then I want the scrapers to ignore my face.

I've experimented with commenting out the code that generates the og:image tag in my Yoast plugin, then hard coding the tag with an empty content attribute into my header.php:

<meta property="og:image" content="" />

This partially achieved the desired effect - Facebook's scraper detects that no image url is specified, but is still seems to be defaulting to whatever other image it can find.

The Open Graph protocol doesn't appear to include behavior for specifying no images, either.

Any thoughts on how I could do this?

EDIT: I just found some workarounds in this question that will probably do the trick, but if anyone has any other ideas, I would appreciate hearing them as well.

回答1:

Upload a blank or 100% transparent image with at least 200x200px and use it in the og:image tag.