WordPress and og:image

The Problem

My WordPress-powered blog automatically posts new articles to Facebook. However, the article image was somehow lost on the way, leading to rather unattractive Facebook posts.

Automatic facebook post without wordpress article image

Automatic facebook post with missing wordpress article image

Digging Into the Issue

It turned out that the problem was a wrong, relative image URL in the og:image meta tag (more on Facebook Open Graph META Tags). When sharing a post, Facebook uses these tags to create the post. And since the image was defined with a relative path, it was simply skipped.

But why does WordPress use a relative image URL?

Out set-up is a multi-user WordPress installation on Linux. We used the settings _$uploadpath and $upload_url_path in the user-specific settings to specify the location of the WordPress uploads folder. And there is one WordPress setting (complete path to files), that must match the $upload_url_path, located in the WordPress admin panel at settings\media. I changed that setting to contain the server URL and everything should be fine now.