Filter hook 'admin_post_thumbnail_size'

in WP Core File wp-admin/includes/post.php at line 1671

View Source

admin_post_thumbnail_size

Filter Hook
Description
Filters the size used to display the post thumbnail image in the 'Featured image' meta box. Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail' image size is registered, which differs from the 'thumbnail' image size managed via the Settings > Media screen.

Hook Information

File Location wp-admin/includes/post.php View on GitHub
Hook Type Filter
Line Number 1671

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 $thumbnail_id Post thumbnail attachment ID.
WP_Post $post The post object associated with the thumbnail.

Usage Examples

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

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

Source Code Context

wp-admin/includes/post.php:1671 - How this hook is used in WordPress core
<?php
1666  		 * @param string|int[] $size         Requested image size. Can be any registered image size name, or
1667  		 *                                   an array of width and height values in pixels (in that order).
1668  		 * @param int          $thumbnail_id Post thumbnail attachment ID.
1669  		 * @param WP_Post      $post         The post object associated with the thumbnail.
1670  		 */
1671  		$size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post );
1672  
1673  		$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
1674  
1675  		if ( ! empty( $thumbnail_html ) ) {
1676  			$content  = sprintf(

PHP Documentation

<?php
/**
		 * Filters the size used to display the post thumbnail image in the 'Featured image' meta box.
		 *
		 * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
		 * image size is registered, which differs from the 'thumbnail' image size
		 * managed via the Settings > Media screen.
		 *
		 * @since 4.4.0
		 *
		 * @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          $thumbnail_id Post thumbnail attachment ID.
		 * @param WP_Post      $post         The post object associated with the thumbnail.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-admin/includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.