wp_ajax_get_post_thumbnail_html

函数
wp_ajax_get_post_thumbnail_html ( No parameters )

wp_ajax_get_post_thumbnail_html: 这个函数是一个WordPress的AJAX处理程序,用于返回给定文章ID的文章缩略图的HTML标记。它以文章ID为参数,在AJAX响应中返回缩略图的HTML标记。

检索特色图片HTML的Ajax处理程序。

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 );
}

常见问题

FAQs
查看更多 >