---
title: Filter standard image URLs in XML image sitemaps
url: "https://www.seopress.org/support/hooks/filter-standard-image-urls-in-xml-image-sitemaps/"
lang: en-US
updated: 2021-09-30
hook_name: seopress_sitemaps_single_img_url
required_version: 3.7.3
---

# Filter standard image URLs in XML image sitemaps

- **Hook name:** `seopress_sitemaps_single_img_url`
- **Required version:** 3.7.3

```php
<?php
// Exclude URLs with specific words
function sp_sitemaps_single_img_url( $url ) {
	// exclude amazon.com URLs: an empty string removes the image from the sitemap
	if ( false !== strpos( $url, 'amazon.com' ) ) {
		return '';
	}
	return $url;
}
add_filter( 'seopress_sitemaps_single_img_url', 'sp_sitemaps_single_img_url' );

// CDN example
function sp_sitemaps_single_img_url2( $url ) {
	// replace a URL with another URL (useful for CDN)
	return str_replace( 'https://seopress.org', 'https://cdn.seopress.org', $url );
}
add_filter( 'seopress_sitemaps_single_img_url', 'sp_sitemaps_single_img_url2' );
```

Source: [https://gist.github.com/wp-seopress/8abe632a511b9685b80844f9534f4e67](https://gist.github.com/wp-seopress/8abe632a511b9685b80844f9534f4e67)



