Filter hook 'post_thumbnail_url'

in WP Core File wp-includes/post-thumbnail-template.php at line 269

View Source

post_thumbnail_url

Filter Hook
Description
Filters the post thumbnail URL.

Hook Information

File Location wp-includes/post-thumbnail-template.php View on GitHub
Hook Type Filter
Line Number 269

Hook Parameters

Type Name Description
string|false $thumbnail_url Post thumbnail URL or false if the post does not exist.
int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`.
string|int[] $size Registered image size to retrieve the source for or a flat array of height and width dimensions. Default 'post-thumbnail'.

Usage Examples

Basic Usage
<?php
// Hook into post_thumbnail_url
add_filter('post_thumbnail_url', 'my_custom_filter', 10, 3);

function my_custom_filter($thumbnail_url, $post, $size) {
    // Your custom filtering logic here
    return $thumbnail_url;
}

Source Code Context

wp-includes/post-thumbnail-template.php:269 - How this hook is used in WordPress core
<?php
 264  	 * @param string|false     $thumbnail_url Post thumbnail URL or false if the post does not exist.
 265  	 * @param int|WP_Post|null $post          Post ID or WP_Post object. Default is global `$post`.
 266  	 * @param string|int[]     $size          Registered image size to retrieve the source for or a flat array
 267  	 *                                        of height and width dimensions. Default 'post-thumbnail'.
 268  	 */
 269  	return apply_filters( 'post_thumbnail_url', $thumbnail_url, $post, $size );
 270  }
 271  
 272  /**
 273   * Displays the post thumbnail URL.
 274   *

PHP Documentation

<?php
/**
	 * Filters the post thumbnail URL.
	 *
	 * @since 5.9.0
	 *
	 * @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. Default is global `$post`.
	 * @param string|int[]     $size          Registered image size to retrieve the source for or a flat array
	 *                                        of height and width dimensions. Default 'post-thumbnail'.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/post-thumbnail-template.php
Related Hooks

Related hooks will be displayed here in future updates.