post_thumbnail_html
Filters the post thumbnail HTML.
Description
apply_filters( 'post_thumbnail_html', (string) $html, (int) $post_id, (string) $post_thumbnail_id, (string|array) $size, (string) $attr );
Parameters (5)
- 0. $html (string)
- The post thumbnail HTML.
- 1. $post_id (int)
- The post id.
- 2. $post_thumbnail_id (string)
- The post thumbnail id.
- 3. $size (string|array)
- The post thumbnail size. Image size or array of width and height values (in that order). Default post-thumbnail..
- 4. $attr (string)
- Query string of attributes.
Usage
- To run the hook, copy the example below.
- $html = apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
- if ( !empty( $html ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the post_thumbnail_html callback
- function filter_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
- // make filter magic happen here...
- return $html;
- };
- // add the filter
- add_filter( 'post_thumbnail_html', 'filter_post_thumbnail_html', 10, 5 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'post_thumbnail_html', 'filter_post_thumbnail_html', 10, 5 );
Defined (1)
The filter is defined in the following location(s).
- /wp-includes/post-thumbnail-template.php
- return apply_filters( 'post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr );