Filter hook 'post_thumbnail_size'

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

View Source

post_thumbnail_size

Filter Hook
Description
Filters the post thumbnail size.

Hook Information

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

Hook Parameters

Type Name Description
string|int[] $size Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
int $post_id The post ID.

Usage Examples

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

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

Source Code Context

wp-includes/post-thumbnail-template.php:184 - How this hook is used in WordPress core
<?php
 179  	 *
 180  	 * @param string|int[] $size    Requested image size. Can be any registered image size name, or
 181  	 *                              an array of width and height values in pixels (in that order).
 182  	 * @param int          $post_id The post ID.
 183  	 */
 184  	$size = apply_filters( 'post_thumbnail_size', $size, $post->ID );
 185  
 186  	if ( $post_thumbnail_id ) {
 187  
 188  		/**
 189  		 * Fires before fetching the post thumbnail HTML.

PHP Documentation

<?php
/**
	 * Filters the post thumbnail size.
	 *
	 * @since 2.9.0
	 * @since 4.9.0 Added the `$post_id` parameter.
	 *
	 * @param string|int[] $size    Requested image size. Can be any registered image size name, or
	 *                              an array of width and height values in pixels (in that order).
	 * @param int          $post_id The post ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/post-thumbnail-template.php
Related Hooks

Related hooks will be displayed here in future updates.