Retrieve the post thumbnail.

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.

When using the_post_thumbnail() or related functions, the ‘post-thumbnail’ image size is used by default, though a different size can be specified instead as needed.

Signature

get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr = '' )
post
 (int|WP_Post) Optional. Post ID or WP_Post object. Default is global `$post`.
Default: null
size
 (string|array) Optional. Image size to use. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default 'post-thumbnail'.
Default: 'post-thumbnail'
attr
 (string|array) Optional. Query string or array of attributes. Default empty.
Default: ''

Return

(string) The post thumbnail image tag.

Source

function get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr = '' ) {
	$post = get_post( $post );
	if ( ! $post ) {
		return '';
	}
	$post_thumbnail_id = get_post_thumbnail_id( $post );

	/**
	 * Filters the post thumbnail size.
	 *
	 * @since 2.9.0
	 * @since 4.9.0 Added the `$post_id` parameter.
	 *
	 * @param string|array $size    The post thumbnail size. Image size or array of width and height
	 *                              values (in that order). Default 'post-thumbnail'.
	 * @param int          $post_id The post ID.
	 */
	$size = apply_filters( 'post_thumbnail_size', $size, $post->ID );

	if ( $post_thumbnail_id ) {
47 more lines...
WP Trac GitHub

Link here