I can confirm this.
I have set an default image. This I need for posts without a picture in and without a set facebook image.
The og: image is set to the defined facebook image. If there is no one defined the default image will be used instead of the first image of the post.
This should be the order:
1. Set Facebook image
2. First image of post
3. Default image from settings
Is there any code I can place to the functions.php to get it working?
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!
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
I have submitted the questions to the devs to see if you can change the order and also use the first image of the content if necessary. We will let you know more once they check it.
Looking forward to helping you. Thank you.
Thanks! I’m happy with every solution… doesn’t matter if there is an option in the settings or I need to update the functions.php…. most important is a quick solution 😉
-
This reply was modified 4 years, 4 months ago by Sven.
Thanks Alberto. I agree with Sven that quick solution is important. Just to reiterate what I noticed was that sometimes RankMath uses the post image (which is correct) but some times it uses the default image. I have shared the examples above. Happy to provide more details so your Developers can reproduce the issue.
Thanks for the help.
Same with me… In the past first conttent image was used, now I can’t find an example where it is used (but havend checked much post, just saw many without using it)
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. ( i.e the src from the first https://os.me/short-stories/flight-or-fancy/
https://os.me/short-stories/its-we-who-rise-its-we-who-set/
On these 2 posts of yours, I don't see any images in the content. The image which is in the banner is a background image. To add the content image in og:image tag, the image must be in the img tag.
Please try adding image in the content or you can set an image in the Facebook tab from Rank Math metabox/sidebar.
I hope that helps.
Hi Patrik,
you missed the default image in your list. This will be bused before 3) and MUST BE after 3)
Check this post: https://esser.me/what-is-a-cx-methodology-and-a-cx-strategy/
circle2.png is the default image which should only be used if 1), 2) and 3) is not available. In this link the strategy-835×362.jpg should be the og:image
If I delete the default image, then the strategy-835×362.jpg will be used… but I need the default image as afallback if there is no other image available.
For sure, I can go and set a Facebook image post by post… but I can’t do this for hundreds of posts. If this is realy needed, I need to switch back to Yoast.
Best
Sven
-
This reply was modified 4 years, 4 months ago by Sven.
Hi Pratik – The two examples that I had given have a featured image. And yes, we are showing featured image a bit differently on the page (as a background on TOP) but it’s a featured image.
My understanding is that it should work. Note that I have given another example of the page where it is working. In fact for most of my posts, the og:image generated by Rankmath is correct. But sometime it doesn’t work And I want to know what’s the difference when it works vs when it doesn’t work. I don’t see any difference in the post itself.
Let me know if you need more details.
Looks like we have a bit different but overlapping issues with the og:image
Hello,
If it’s featured image then it should take priority over the default image.
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,
Thank you for providing access. I checked the 2 posts on your site which are not showing the featured image.
https://os.me/short-stories/flight-or-fancy/
https://os.me/short-stories/its-we-who-rise-its-we-who-set/
The reason why Rank Math is not adding the featured image on these 2 posts is that the image dimensions are less than the required dimension. The required dimensions are:
Width: Min 200px & Max 2000px
Height: Min 200px & Max 2000px
In both the posts, the height of featured image is 168px so Rank Math is not adding it. Please try adding bigger images, that will fix the issue.
I hope that helps.
Thank you Pratik for the response. I updated the image in https://os.me/short-stories/flight-or-fancy/ and now it’s more than 200px, Rankmath is still not using the featured image. Not sure if I am missing anything here.
Hello,
It looks like we are using the same og:image
as your featured image:
Could you please try after clearing your cache? As far as I can tell, Rank Math is outputting the og:image
correctly.
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.