wp_ajax_get_post_thumbnail_html() WordPress Function

The wp_ajax_get_post_thumbnail_html() function is used to retrieve the post thumbnail HTML for a given post ID. This function is used internally by the WordPress Ajax handler and should not be called directly.

wp_ajax_get_post_thumbnail_html() #

Ajax handler for retrieving HTML for the featured image.


Source

File: wp-admin/includes/ajax-actions.php

function wp_ajax_get_post_thumbnail_html() {
	$post_ID = (int) $_POST['post_id'];

	check_ajax_referer( "update-post_$post_ID" );

	if ( ! current_user_can( 'edit_post', $post_ID ) ) {
		wp_die( -1 );
	}

	$thumbnail_id = (int) $_POST['thumbnail_id'];

	// For backward compatibility, -1 refers to no featured image.
	if ( -1 === $thumbnail_id ) {
		$thumbnail_id = null;
	}

	$return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
	wp_send_json_success( $return );
}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More