ACF image not connecting into OG:Image

#468174
  • Resolved Jason Alward
    Rank Math free

    Hello. I’m having issues with my ACF field group. I use ACF to put in data for Rank Math. Below is this code I have for adding a 1200×630 image as a Facebook Share Image. But no matter what, I’m getting a “The ‘og:image’ property should be explicitly provided, even if a value can be inferred from other tags.” message from Facebook Debugger.

    In the code below, “social” is the group, “image” is the sub field. The image field is set to array

    add_filter( ‘rank_math/opengraph/facebook/og_image’, function( $fbimage ) {
    global $post;
    $fbimage = get_field(‘social_image’, $post->ID); /* Insert specific field here */
    return $fbimage;
    });

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hello,

    Thanks for contacting us, and sorry for any inconvenience that might have been caused due to that.

    Can you please share the affected URLs with us? So that we can investigate the issue further for you.

    Looking forward to helping you.

    Thank you.

    Yes, it’s [moved to sensitive data section]

    I’m attempting to add a custom og:image to the home page

    ACF Fields

    I’ve set up a login for your if it helps

    Anas
    Rank Math business

    Hello,

    I tried to log in to your website but it seems you have 2-factor authentication.

    Can you please disable 2FA temporarily so we can check?

    We look forward to helping you.

    Oh sorry about that. I just disabled it

    Hello,

    The issue may have been due to the configuration of your custom field. The current settings for your “Custom Social Image” is to return an image array as you can see in my screenshot:

    array

    Whereas, the filter code should accept a string of absolute URL or path of the image. Please try switching “Image URL” as a Return Format instead in your ACF settings, clear your website cache and check the page again.

    Let us know how that goes. Looking forward to helping you with this one.

    Hi. Thanks for your continued help. I had tried that (tried it again now), and it doesn’t work. When I look in the Rank Math Preview Snippet Editor, it still shows the placer image that says “Please Upload Image”

    Interestingly, when I look at the head page source, I don’t see the OG:Image…but I do see the twitter:image meta…and it showing the correct image URL

    Hello,

    I had tried that (tried it again now), and it doesn’t work. When I look in the Rank Math Preview Snippet Editor, it still shows the placer image that says “Please Upload Image”

    Since you are using a filter, the snippet editor will not be updated. The filter code will only reflect on the frontend. You may ignore this as long as the filter is working on the frontend.

    Interestingly, when I look at the head page source, I don’t see the OG:Image…but I do see the twitter:image meta…and it showing the correct image URL

    There is an issue with the filter code and I have corrected it. The og:image is now showing. Please clear your website cache and check it again on your end.

    Looking forward to helping you with this one.

    Thanks for your help on this. It does work…and did work, until I deactivated a plugin. Customer Upload Files for WooCommerce.

    I now get a PHP error…

    Warning: Illegal string offset ‘url’ in /home/customer/www/erinarsenaultart.com/public_html/wp-content/plugins/seo-by-rank-math/includes/opengraph/class-image.php on line 226

    Do I need to login to my mySQL and delete that plugin’s table?

    Hello,

    You need to ensure that the custom field “social_image” is returning a valid URL. In your filter code, you may add a fallback whenever the get_field function returns an unwanted result.

    Looking forward to helping you with this one.

    Hi. I’m not a programmer by trade, so I’m not familiar with the get_field function.

    But when I look at the page source, I do see that the OG:Image is getting a URL:

    <meta property=”og:image” content=”https://erinarsenaultart.com/wp-content/uploads/2022/10/EA-share-graphic-b.jpg&#8221; />

    Again, this happens when I deactivate the “Customer Upload Files for WooCommerce” plugin. Is this a database corruption issue? Would deleting both this plugin and Rank Math…and reinstalling help?

    I found this previous issue. It looks similar to mine. Something about a corrupted schema

    https://support.rankmath.com/ticket/illegal-string-offset-type/

    Hi. So in a weird way, I did a work around.

    When I put default OG image in the settings, it corrected the PHP error. I was then able to put a custom image in my page.

    Is a default image necessary in the settings? Just wondering. Seems odd that that would cause a PHP error.

    Hello,

    That is not actually an error but rather a warning and that happens because the plugin cannot find the key url in the attachment.

    This is not the same issue as the one you shared from another ticket since it’s happening in a different file from a different module of our plugin.

    As for the question about the default image, that is not necessary but rather advisable to add it so there’s at least a fallback for pages without a specific image.

    Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    In any event. That’s what was causing the error. Once I put an image in the default setting, the issue resolved itself. Not sure if this is a bug with the RankMath or not…but in any event, this is what happened in my case.

    I was able to delete the other plugin, as I now have a default OG image in the setting. It’s a weird work around, but hopefully a future upgrade will fix it.

    Thanks for your help.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 15 replies - 1 through 15 (of 16 total)

The ticket ‘ACF image not connecting into OG:Image’ is closed to new replies.