Filter hook 'post_thumbnail_html'

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

View Source

post_thumbnail_html

Filter Hook
Description
Filters the post thumbnail HTML.

Hook Information

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

Hook Parameters

Type Name Description
string $html The post thumbnail HTML.
int $post_id The post ID.
int $post_thumbnail_id The post thumbnail ID, or 0 if there isn't one.
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).
string|array $attr Query string or array of attributes.

Usage Examples

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

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

Source Code Context

wp-includes/post-thumbnail-template.php:236 - How this hook is used in WordPress core
<?php
 231  	 * @param int          $post_thumbnail_id The post thumbnail ID, or 0 if there isn't one.
 232  	 * @param string|int[] $size              Requested image size. Can be any registered image size name, or
 233  	 *                                        an array of width and height values in pixels (in that order).
 234  	 * @param string|array $attr              Query string or array of attributes.
 235  	 */
 236  	return apply_filters( 'post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr );
 237  }
 238  
 239  /**
 240   * Returns the post thumbnail URL.
 241   *

PHP Documentation

<?php
/**
	 * Filters the post thumbnail HTML.
	 *
	 * @since 2.9.0
	 *
	 * @param string       $html              The post thumbnail HTML.
	 * @param int          $post_id           The post ID.
	 * @param int          $post_thumbnail_id The post thumbnail ID, or 0 if there isn't one.
	 * @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 string|array $attr              Query string or array of attributes.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/post-thumbnail-template.php
Related Hooks

Related hooks will be displayed here in future updates.