Open Graph Preview Blank

On one of our sites, open graph preview image is blank for one of the pages. I have opened the url in the sharing debugger and the preview shows correct but does report a warning for invalid image url. When I open the image url, it displays the image fine. I have OG enabled and a fallback image set in the theme options.

I don’t want to install Yoast just for this. Is it because its a page? The page is a Cornerstone page (Pro 6.1.2). Are we missing some image metadata somewhere?

The page in question is EHSD Program Data Dashboard | EHSD

Thanks.

Hi Kevin,

Thanks for reaching out.
It is not clear how you have added those OG values. I have checked it and found that og:image is set with the Image ID not the image URL, and that is the reason behind your problem. I would suggest you check the code which adds the value.

Screenshot-2023-02-17-190341

Please remember that we don’t offer any support to the custom code or 3rd party plugin issue.

Thanks

The OG values are straight from whatever Pro adds via the enable Open Graph option in the theme settings. We aren’t using any other SEO plugins or any custom code in functions/child theme.

The image shown in the FB debugger preview is added as a background to a div with a section/row/column as parents. The div has child headline and gap elements.

Looks like the ID is from Cornerstone and is not properly being converted to the full image URL.

Hello Kevin,

I have investigated the issue and I believe that this is a bug. Temporarily, you can resolve it by adding this custom PHP code to your child theme:

// Get Featured Image URL (With Social Fallback Image)
// =============================================================================

if ( ! function_exists( 'x_get_featured_image_with_fallback_url' ) ) :
  function x_get_featured_image_with_fallback_url( $size = 'full' ) {

    $featured_image_url = x_get_featured_image_url( $size );

    if (!$featured_image_url) {
      $img = get_option( 'x_social_fallback_image' );

      $parts = explode(':', $img);
      $attachment_id = intval($parts[0]);
      
      $featured_image = wp_get_attachment_image_src( $attachment_id, $size );

      return $featured_image[0];
    }

    return $featured_image_url;

  }
endif;

Kindly let us know how it goes.

Great. I will give that a try this week. Do you know if this bug will be addressed anytime soon via an update?

Hi Kevin,

My colleague has already reported this, but unfortunately, we don’t have any ETA on this. I would request you try the code given by my colleague and let us know how it goes for you.

Thanks

Gotcha. Will do.

I added to my child theme functions.php and no change reported after rescraping in the Meta dev sharing debugger

Hello Kevin,

Please clear your plugin caches first. It seems that the WP-Optimize plugin is serving a cache version which is why the updated Open Graph image is still not displaying.

Best Regards.

I’ve tried this with no change. I emptied WPO and Cloudflare caches and rescraped the URL, no preview and same warning in the FB debugger.

Hey Kevin,

This should have worked already because when I did the test, I am seeing the image.

  • See the secure note below

Best Regards.

I’ll look into this. Might be something on my end in the browser. Thank you.

You’re most welcome. Please let me know if you need any further assistance.

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