post_thumbnail_url filter-hookWP 5.9.0

Filters the post thumbnail URL.

Usage

add_filter( 'post_thumbnail_url', 'wp_kama_post_thumbnail_url_filter', 10, 3 );

/**
 * Function for `post_thumbnail_url` filter-hook.
 * 
 * @param string|false     $thumbnail_url Post thumbnail URL or false if the post does not exist.
 * @param int|WP_Post|null $post          Post ID or WP_Post object.
 * @param string|int[]     $size          Registered image size to retrieve the source for or a flat array of height and width dimensions.
 *
 * @return string|false
 */
function wp_kama_post_thumbnail_url_filter( $thumbnail_url, $post, $size ){

	// filter...
	return $thumbnail_url;
}
$thumbnail_url(string|false)
Post thumbnail URL or false if the post does not exist.
$post(int|WP_Post|null)
Post ID or WP_Post object.
Default: global $post
$size(string|int[])
Registered image size to retrieve the source for or a flat array of height and width dimensions.
Default: 'post-thumbnail'

Changelog

Since 5.9.0 Introduced.

Where the hook is called

get_the_post_thumbnail_url()
post_thumbnail_url
wp-includes/post-thumbnail-template.php 265
return apply_filters( 'post_thumbnail_url', $thumbnail_url, $post, $size );

Where the hook is used in WordPress

Usage not found.