og_image_width and og_image_height hook not working with cdn image

#568067
  • Resolved Anonymous
    Rank Math free

    Hello Rank Math support team,
    I am trying to customize the Open Graph image width and height for an external image with a CDN on my website. To achieve this, I have added the following code to my rank-math.php file:

    
    add_filter( "rank_math/opengraph/facebook/og_image_width", function( $content ) {
    	$content = '1000';
    	return $content;
    });
    
    add_filter( "rank_math/opengraph/facebook/og_image_height", function( $content ) {
    	$content = '1000';
    	return $content;
    });
    

    However, I have noticed that the og:image:width and og:image:height tags are not showing up in the source code when I view the page. Could you please help me determine why the filters are not working as expected and how I can resolve this issue?

    Thank you for your assistance.

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    We have tested the code you have shared, and it seems to be working fine. Please refer to the screencast in the sensitive data section.

    Could you please check again if the Opengraph tags are showing when you remove/disable the filter? Also, in the rank-math.php file, please ensure that you have included the opening PHP tag <?php before the filter.

    Meanwhile, you can also try applying the filter using a different method here:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Looking forward to helping you.

    Thank you.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.