Option for default og image logic

#28883
  • Resolved Michael Baierl
    Rank Math free

    Right now the OG image is determined using the following logic (within the function get_thumbnail_with_fallback @ line 249 @ seo-by-rank-math/includes/helpers/class-wordpress.php):

    1. post thumbnail
    2. first image within the content
    3. fb/twitter image of post
    4. default og image from settings

    I see two issues with that logic:
    1) the set fb/twitter image should have a higher priority than the first image of the post content
    2) add an (global) option to disable the “first image within the content” logic, so I can use images but still use the default OG image…

    Thanks, Michael

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I have submitted this problem to our dev team and we will be getting back to you in a short while.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hi Michael,

    the following code in the functions.php solves the issue:

    
    add_filter('rank_math/opengraph/pre_set_content_image', function() {
    	return true;
    });
    

    However it would be amazing to have a simple setting for that… using the first image of a page/post is not always sufficient…

    Michael

    Todd
    Rank Math free

    Hi Michael,

    Thank you for your input.

    By default, Rank Math is set up to use the featured image of a post as its open graph image. If there is no featured image, we use the fallback option you used while using the setup wizard or at WordPress Dashboard > Rank Math > Titles & Meta > Global > OpenGraph Thumbnail.

    Are you using the Gutenberg or Classic Editor to test this?

    Hi,
    I use Elementor. And as I said, the above filter works fine to fix the issue. The code which calls the filter uses the logic:
    – featured image
    – first image in the content
    – default image

    Best regards,
    Michael

    Todd
    Rank Math free

    Hi Michael,

    I appreciate it so much.

    We haven’t heard any complaints about this yet and I have shared your feedback with the dev. team.

    I am sure this will be helpful.

    If you need help with anything else, please open a new support ticket here so we can help.

    We are always here for assistance.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Option for default og image logic’ is closed to new replies.