_wp_post_thumbnail_html example



/** * Displays post thumbnail meta box. * * @since 2.9.0 * * @param WP_Post $post Current post object. */
function post_thumbnail_meta_box( $post ) {
    $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
    echo _wp_post_thumbnail_html( $thumbnail_id$post->ID );
}

/** * Displays fields for ID3 data. * * @since 3.9.0 * * @param WP_Post $post Current post object. */
function attachment_id3_data_meta_box( $post ) {
    $meta = array();
    
$thumbnail_id = (int) $_POST['thumbnail_id'];

    if ( $json ) {
        check_ajax_referer( "update-post_$post_id);
    } else {
        check_ajax_referer( "set_post_thumbnail-$post_id);
    }

    if ( '-1' == $thumbnail_id ) {
        if ( delete_post_thumbnail( $post_id ) ) {
            $return = _wp_post_thumbnail_html( null, $post_id );
            $json ? wp_send_json_success( $return ) : wp_die( $return );
        } else {
            wp_die( 0 );
        }
    }

    if ( set_post_thumbnail( $post_id$thumbnail_id ) ) {
        $return = _wp_post_thumbnail_html( $thumbnail_id$post_id );
        $json ? wp_send_json_success( $return ) : wp_die( $return );
    }

    
Home | Imprint | This part of the site doesn't use cookies.