Hello,
Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.
I can check that the images in your posts are being added as the background images. The background images are not added to the page as actual images, they are added as background style using CSS and that’s why our plugin is not including them in the sitemap.

You can modify and use the following filter to add the images manually in the sitemap: https://rankmath.com/kb/filters-hooks-api-developer/#remove-change-images
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope this helps. Let us know if you need any other assistance.
Hi. and thanks for response, and Im still having a problem
I followed the instructions of method 2,
1. created file inside theme folder. (thrive theme builder is different, so I think this is the correct location)
2. pasted below hook under wordpress/theme file editor/rankmath.php
3. however when I add the hook, it throws the “error at line one, column one.” And the page is blank.
/**
* Filter images to be included for the post in XML sitemap.
*
* @param array $images Array of image items.
* @param int $post_id ID of the post.
*/
add_filter( ‘rank_math/sitemap/urlimages’, function( $images, $post_id ){
return $images;
}, 10, 2);
Also, I use optimole for image CDN. So, Not sure if that needs to be addressed.
Thank you in advance for any guidance on getting the images properly. Its an art website, so that is important to us.
Hello,
Please note, the the CSS background images may still not be picked up by search engines, even if they are in the sitemap. You can check this article for reference: https://iloveseo.com/news/google-explains-how-to-handle-css-background-hero-images/
The ideal solution would be to go into each post and change each background image to an <img> tag. I understand how tedious it is but it will give the results you desire.
If you still wish to proceed with adding the images to the sitemap, the filter is not complete and would need to be modified to pull the image URLs. The amount of customization involved is beyond the scope of our support. If you are not comfortable with editing the code you can hire a developer from a place like codable.io.
Hope that helps. Please let us know if you have questions.
No, this doesnt help. I have thousands of images, and growing to tens of thousands. So, I need a site wide solution.
You guide shows how to put the code into effect, yet its breaking my sitemap. Can you please help me understand how to get it to not break my sitemap. Clearly I made some mistake. And Im asking for help, if you can please tell me where I made a mistake implementing this into thrive themes
Hello,
Here is an example of how to use the code:
add_filter( 'rank_math/sitemap/urlimages', function( $images, $post_id ){
if ( $post_id == '120') {
$images[] = [
'src' => 'http://localhost:10029/wp-content/uploads/2022/04/4538727-PH-LOS-NARANJOS-MERCEDES-01.png',
'title' => 'My image title'
];
return $images;
}
return $images;
}, 10, 2);
You will have to modify it according to the IDs of your posts and image details in the images array for it. And make sure to add an opening PHP tag <?php in the file before the code. However, as mentioned by my colleague even if you add the images in the sitemap, Google will still not consider them for the SERPs as they are background images. So if you want to index your images for the image search then you should add them to the posts as normal images and not as the background images.
Hope this helps. Let us know if you need any other assistance.
Thanks.
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.