wp_ajax_get_post_thumbnail_html

The timeline below displays how wordpress function wp_ajax_get_post_thumbnail_html has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Handles retrieving HTML for the featured image via AJAX.
 *
 * @since 4.6.0
 */
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);
}

WordPress Version: 6.2

/**
 * Ajax handler for retrieving HTML for the featured image.
 *
 * @since 4.6.0
 */
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);
}

WordPress Version: 5.6

/**
 * Ajax handler for retrieving HTML for the featured image.
 *
 * @since 4.6.0
 */
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);
}

WordPress Version: 4.6

/**
 * Ajax handler for retrieving HTML for the featured image.
 *
 * @since 4.6.0
 */
function wp_ajax_get_post_thumbnail_html()
{
    $post_ID = intval($_POST['post_id']);
    check_ajax_referer("update-post_{$post_ID}");
    if (!current_user_can('edit_post', $post_ID)) {
        wp_die(-1);
    }
    $thumbnail_id = intval($_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);
}