Facebook link not showing correct Item image

When I paste a link to an Item/show page to Facebook it doesn’t show the Image but shows the page header. I’ve tried rescraping the page in the Facebook debugger and although it then shows the correct image in the debugger the FB link still doesn’t. And anyway, doing this with individual items is not practical.

The FB debugger says ‘og.image’ should be specified - is there a way to do this in Omeka? Maybe a plugin to add the og info automatically?

I tried adding this to the header in out theme:

<meta property="og:image" content="<?php echo files_for_item(array('imageSize' => 'thumbnail')); ?>" />

But it threw up an extra copy of the image at the top of the page, followed by " /> is there something wrong with that code that means the parser is misinterpreting it?

files_for_item returns the markup for the whole image, where the og:image property wants just a URL.

Use metadata($item->getFile(), 'fullsize_uri') instead.

1 Like

Thanks John, just need to find a way to check if it’s the items/show page now - any thoughts?

Just if(isset($item)) probably gets you most of the way really. Otherwise, you can check more explicitly:

$request = Zend_Controller_Front::getInstance()->getRequest();
if ($request->getModuleName() === 'default'
    && $request->getControllerName() === 'items'
    && $request->getActionName() === 'show'
) {

Thanks again John - a very helpful friend managed to get it working with this code (but I will pass your suggestion on to him (although he’s probably watching anyway):

Code snippet to resolve issues with Facebook not displaying images via Omeka Social Bookmarking plugin
Add to an Omeka Classic Theme’s /common/header.php to output …

<?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; ?>

Thanks again!

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.