How to get full absolute url for post attachment?
I'm trying to manually fill the Open Graph tags and I'm having some troubles in setting the content for the og:image
tag.
In a single post page, I set it this way:
?php
$thumbnailSrc = wp_get_attachment_image_src(get_post_thumbnail_id($post-ID), 'medium');
$image = esc_attr($thumbnailSrc[0]);
?
meta property="og:image" content="?php echo $image ?"
The result is this:
meta property="og:image" content="/wp-content/uploads/image.jpg"
On the Open Graph debugger I then get this error:
Object at URL 'http://website.com' of type 'article' is invalid because the given value '/wp-content/uploads/image.jpg' for property 'og:image:url' could not be parsed as type 'url'.
How can I get the attachment so that the url is: http://website.com/wp-content/uploads/image.jpg ?
Topic open-graph post-thumbnails images Wordpress
Category Web