• featherodd

    (@featherodd)


    Anyone know a custom function or plugin to get the post-thumbnail src added to the header as a image meta tag so that facebook will properly pick up the thumbnail when a single post is passed to http://www.facebook.com/sharer.php

    <meta name="image_type" content="POST-THUMBNAIL" />
    <link rel="image_src" href="'POST-THUMBNAIL'" />
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter featherodd

    (@featherodd)

    tried a bunch of solutions and this seemed to do the trick:

    added this to functions.php:

    function get_post_thumbnail_url() {
    	$thumbnail_id=get_the_post_thumbnail($post->ID, thumbnail);
    	preg_match ('/src="(.*)" class/',$thumbnail_id,$link);
    	echo $link[1];
    }

    and this to my header:

    <?php if (is_home()) : ?>
    	<meta property="og:type" content="blog" />
    <?php else : ?>
    	<meta property="og:type" content="article">
    	<link rel="image_src" type="image/jpeg" href="<?php get_post_thumbnail_url() ?>" />
    	<meta property="og:image" content="<?php get_post_thumbnail_url() ?>"/>
    <?php endif; ?>

    I’m having the same problem but this code isn’t working for me. Any help?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘post thumbnail as facebook share thumbnail’ is closed to new replies.