-
This is my blog https://www.stay-here.com.tw/, I recently found that the correct picture was not ran out when sharing facebook. I only found the OG:image missing after looking at the source code, I don’t know how to deal with it
-
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
Please ensure you have set an open graph image for your site in Rank math > Titles & Meta > Global Meta. You should also check your page to ensure you have set a social image in Rank math Social metabox.
If you have set all this and the image is still not showing we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
Hello, after replacing the picture, og:image does appear on the homepage, but other articles and pages are also applied to the og:image of the homepage. I don’t know of any way to let og:image grab the selected pictures of their articles.
Hello,
Could you share the login data following the steps my colleague shared so we can log in your website and check everything is fine?
Looking forward to help you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Open the permissions, please help me to confirm
Hello,
I have checked your site page source and now the
og:image
tags seem to be added and the image is showing fine in facebook debugger, here is a screenshot: https://i.rankmath.com/ciWspnIf you have any further question(s), please let us know. Thank you.
Yes! At present, OG:IMG has appeared, but the articles and pages are all captured by the same IMG, and there are no selected pictures of individual articles.
Like this: https://www.stay-here.com.tw/floret/
I also grabbed the photos you shared with me…Hello,
I checked it and it is showing the global image because you didn’t set a Facebook image for each post so it is following this order:
1. Does it have a Facebook image in the post? Yes? Show it. No? Go to the next option.
2. Does it have a global image set for all the posts? Yes? Show it. No? Go to the next option.
3. Does it have a featured image set in the post? Yes? Show it. No? Let Facebook decide what to show.In your case, since your post doesn’t have a Facebook image, it checks if you have a global image set for Facebook and since you have, it shows it.
I set a post with a Facebook image (I added the link in the Sensitive Data section) and as you can check here: https://developers.facebook.com/tools/debug/ It is now showing your featured image.
Looking forward to help you.
Beetween 1 and 2 there should be a check for the first image in content. Only if there is no Facebook image set, no content image exists and no feature image is in place, the default (global) image should be used.
Any chance to get the content image as step 2?
This code doesn’t help to get the first image as the og:image if there is no Facebook image set. I still get the default image placed… but there is a content image.
add_filter('rank_math/opengraph/pre_set_content_image', function() { return true; });
However, if this would work, the next question is what happens if there is a set Facebook picture!? The content picture should only be used as the second option!
Understand, because I have selected photos of the article, I don’t know if he can grab the featured pictures by himself?
Hello,
I have just asked the devs about it and we will send you a message once they check it.
Looking forward to help you.
Thanks Alberto
With the situation right now I have the default image at all posts which have not manualy assigned the facebook image. Going into hundreds of posts and assign the same image like the first content image as the facebookk image is impossible. If this is the case, I would need to goo back to Yoast.
Hello,
Following is the priority in which Rank Math adds an image in the og:image tag:
1) The Image set in the Social >> Facebook field
2) The featured image
3) The first image from the content.
4) The default image from the Settings.On your site, Rank Math is not adding the first image from the content because you are using an external image source.
This is a bug in the plugin and I have logged it. Please allow us some time to test and release a fix. It should be added to the plugin in upcoming updates.
For now, to fix the issue on your site, please add following code to your theme’s functions.php file:
add_filter( 'rank_math/opengraph/facebook/image', 'rank_math_set_content_image' ); add_filter( 'rank_math/opengraph/twitter/image', 'rank_math_set_content_image' ); function rank_math_set_content_image( $attachment_url ) { if ( $attachment_url || ! is_singular() ) { return $attachment_url; } global $post; if ( has_post_thumbnail() || get_post_meta( $post->ID, 'rank_math_facebook_image_id', true ) ) { return $attachment_url; } $content = $post->post_content; $images = []; if ( preg_match_all( '<code><img [^>]+></code>', $content, $matches ) ) { foreach ( $matches[0] as $img ) { if ( preg_match( '<code>src=(["\'])(.*?)\1</code>', $img, $match ) ) { if ( isset( $match[2] ) ) { $images[] = $match[2]; } } } } if ( ! empty( $images ) ) { return $images[0]; } return $attachment_url; }
I hope that helps.
PPratik, I have the same issue WITHOUT having an external image. So this is my situation:
1) The Image set in the Social >> Facebook field
No image set2) The featured image
No image set3) The first image from the content.
The first content of the post is an internal image. This is not used by Rank Math4) The default image from the Settings.
Rank Math is using this image as the og: imageHere is an example post: https://esser.me/what-is-a-cx-methodology-and-a-cx-strategy
Should I try your code or does it not help in my case?
- This reply was modified 4 years, 4 months ago by Sven.
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.
The ticket ‘No og: image’ is closed to new replies.