Change social share image size?

#545406
  • Resolved Sunny T
    Rank Math free

    Hey there!

    I have a site that showcases screenshots of other websites.

    Each screenshot is a post within a CPT, and the screenshot is the featured image for the post.

    Because the screenshot is often quite long (ex: 1400px x 15000px), it either looks weird or doesn’t show at all when sharing the post on FB or Twitter.

    I have a custom image size setup that’s 800x800px, which is what I use for my post archive.

    Is there any filter I could use that would set this thumbnail size as the social share image for the post? And not the full size image?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Used ChatGPT and it seems like something like this works:

    function custom_rankmath_social_share_image_sizes( $sizes ) {
        if ( is_singular( 'my_cpt_name' ) ) {
            // Add 'my-custom-img-size' as the first priority size for 'step' post type
            array_unshift( $sizes, 'my-custom-img-size' );
        }
        return $sizes;
    }
    add_filter( 'rank_math/opengraph/image_sizes', 'custom_rankmath_social_share_image_sizes', 10, 1 );

    Let me know if that should cause any issues 🙂

    Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Glad that you found a solution using chatGPT.

    If it’s working fine for you, then it should not cause any issues. You’re free to use the code.

    However, if you encounter any issues further, feel free to let us know here, or creating a new support ticket and we’ll be assisting you with those.

    Thank you.

    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 2 replies - 1 through 2 (of 2 total)

The ticket ‘Change social share image size?’ is closed to new replies.