_wp_post_thumbnail_html

Definition:
function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {}

Output HTML for the post thumbnail meta-box.

Parameters

  • int $thumbnail_id: ID of the attachment used for thumbnail

Return values

returns:html

Defined filters

  • admin_post_thumbnail_html
    apply_filters( 'admin_post_thumbnail_html', $content )

Source code

function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {

	global $content_width, $_wp_additional_image_sizes, $post_ID;

	$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="' . esc_url( get_upload_iframe_src('image') ) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';

	$content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));



	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {

		$old_content_width = $content_width;

		$content_width = 266;

		if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )

			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );

		else

			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );

		if ( !empty( $thumbnail_html ) ) {

			$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_ID" );

			$content = sprintf($set_thumbnail_link, $thumbnail_html);

			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';

		}

		$content_width = $old_content_width;

	}



	return apply_filters( 'admin_post_thumbnail_html', $content );

}

4409

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: