CDN image indexing

#451237
  • Resolved K B
    Rank Math free

    Hello – I just purchased your plugin, and I wanted to confirm if I needed to do anything in regards to CND image indexing. I know in YOAST I had to add a few lines to the functions tab.

    This line actually

    function wpseo_cdn_filter($uri) {
    return str_replace(‘https://www.example.com’, ‘https://secureservercdn.net/example.com/’, $uri);
    }

    add_filter( ‘wpseo_xml_sitemap_img_src’, ‘wpseo_cdn_filter’ );

    I wanted to know if this is needed with your plugin as well.

    Thank You

Viewing 1 replies (of 1 total)
  • Anas
    Rank Math business

    Hello,

    Thank you for contacting Rank Math.

    You need to add this filter to add the CDN Image URLs in the sitemap:

    /**
     * Filter to Add CDN Image URLs in the Sitemap
     *
     * @param string $src  Image URL.
     * @param object $post Post object.
     */
    add_filter( 'rank_math/sitemap/xml_img_src', function( $src, $post ){
    	$src = str_replace( 'http://domain.com', 'https://cdn.domain.com', $src );
    	return $src;
    }, 10, 2);
    

    Change the domain with your actual domain name.

    Hope this helps.

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

The ticket ‘CDN image indexing’ is closed to new replies.