1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

FB Open Graph image not displaying

Discussion in 'PHP' started by nickp87, Jul 19, 2017.

  1. #1
    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');
    ?>
    PHP:
    <meta property="og:title" content="<?php echo $titles[array_rand($titles)]; ?>" />
    <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" />
    HTML:
    Facebook debugger shows the preview as this (no errors)

    [​IMG]


    Open Graph debugger shows

    [​IMG]

    Sorry if i have missed anything, or i have this is the wrong place, getting this far on what i though was simple thing has been hard enough and any help will be greatly appreciated.
    SEMrush
     
    nickp87, Jul 19, 2017 IP
    SEMrush
  2. JEET

    JEET Notable Member

    Messages:
    3,487
    Likes Received:
    422
    Best Answers:
    16
    Trophy Points:
    235
    #2
    JEET, Jul 27, 2017 IP