FB OpenGraph image not displaying

Hi all

I am working on some php code to randomly select og meta from a list of choices to change the website preview when you share a link on Facebook, so far it’s going well, the title and description are working and are random, the issue is the images aren’t displaying.

Using FB debugging i can see it is calling the correct images and the links to the images work, they are just not displayed when the URL is posted to FB.

My code so far

<?php
$titles = array('title1', 'title2', 'title3');
$images = array('http://portfolio.innofydesign.com/ogimage/1.jpg', 'http://portfolio.innofydesign.com/ogimage/2.jpg', 'http://portfolio.innofydesign.com/ogimage/3.jpg');
$descriptions = array('description1', 'description2', 'description3');
?>

<meta property="og:url" content="http://portfolio.innofydesign.com/ogimage/" />
<meta property="og:title" content="<?php echo $titles[array_rand($titles)]; ?>" />
<meta property="og:image" content="<?php echo $images[array_rand($images)]; ?>" />
<meta property="og:description" content="<?php echo $descriptions[array_rand($descriptions)]; ?>"/>
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />

Facebook debugger shows the preview as this (no errors)


OpenGraph debugger shows

Sorry if i have missed anything, getting this far on what i though was simple has been hard enough and any help will be greatly appreciated.

This does not look like a PHP question. The script appears to be doing exactly what you ask of it and outputting the desired html. Things seem OK in the debugger too.
So this may be more about what FB actually does with the tags you give it. Is it forced to use them, or will make its own choice.
I notice you are using the very minimum image size that is accepted at 200x200, while you would expect that to work, they do recommend larger images, have you tried that?

1 Like

Hi Sam, thanks for the reply.

Yes min image size was only used as a test, i will try changing them.

In theory FB should use the open graph meta tags to display what you tell it, but it is FB so who knows.

The open graph debugger shows the images fine so i know it’s not an issue there.

Where would you advise i post for the most relevant help, is there a FB dev sub forum :slight_smile:

I moved it to the Social Media forum.

Thank you Sam but i think you nailed it with your first reply, feel a bit silly for not checking image sizing but as there was no error i guess my laziness kicked in and i assumed it was fine.

Thanks again for the help.

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