Facebook link not showing correct Item image (again)

Hi - I am trying to work out what to do with my facebook link - when I share an item on Facebook it is just showing the header image on Facebook and no item thumbnail when I share… Now there is a forum post with exactly the same problem from a couple of years ago and an answer… but I had a go at following the conversation, but I need a bit more explanation… sorry!!! I am using Northfield-master theme… perhaps the code has moved on since this last post… can anyone give some clues/advice?

Thank you xx

Hi, @ClaireH.
Could you please provide an example of the links you’re sharing on FB?

1 Like

Hi there! I was using the Social Bookmarking Plugin and trying to share from the ‘item’ page… I have given up with the plugin and deactivated it.

I have now changed the header.php for the theme (added the og meta tag ) with the result that trying to share from the item url as a post in Facebook now offers the option of every picture on the page to choose from… this is helpful in the respect that I can now un-check the header image and only choose the item image. So it’s kind of solved… however it isn’t a very sophisticated fix… I can’t just easily share, and any visitor who shares an item will probably not realise and continue to share the header image first so only showing that. Which is annoying. I look forward to any og meta tag code that solves the problem in a nicer way… I have probably already exceeded my skill set in working out how to do this :slight_smile:

Claire x

What og meta tag did you add, specifically?

Sorry I missed this, apologies.
I used H_Gregg’s code from his thread at line 17 in my header.php for the theme:

<?php if ($bodyclass=='items show'):?>          #bodyclass may vary in different themes 'item show' might be used
    <?php $item = get_current_record('item')?>   
    <?php $myimage = metadata($item->getFile(), 'thumbnail_uri'); ?>
    <meta property="og:image" content="<?php echo $myimage ?>">
<?php endif; ?>

If I go into facebook and try to post a link eventually this shows up the header AND the item. Facebook allows me to delete the header image. Its a pain but it works well enough.