wp_ajax_get_post_thumbnail_html

Ajax handler for retrieving HTML for the featured image.

Description

wp_ajax_get_post_thumbnail_html(); 

Usage

  1. if ( !function_exists( 'wp_ajax_get_post_thumbnail_html' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_get_post_thumbnail_html(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_get_post_thumbnail_html() { 
  2. $post_ID = intval( $_POST['post_id'] ); 
  3.  
  4. check_ajax_referer( "update-post_$post_ID" ); 
  5.  
  6. if ( ! current_user_can( 'edit_post', $post_ID ) ) { 
  7. wp_die( -1 ); 
  8.  
  9. $thumbnail_id = intval( $_POST['thumbnail_id'] ); 
  10.  
  11. // For backward compatibility, -1 refers to no featured image. 
  12. if ( -1 === $thumbnail_id ) { 
  13. $thumbnail_id = null; 
  14.  
  15. $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); 
  16. wp_send_json_success( $return );