Make WordPress Core


Ignore:
Timestamp:
10/07/2009 10:18:09 PM (16 years ago)
Author:
markjaquith
Message:

First pass on canonical post thumbanils. Admin-side GUI only. Theme functions to follow. see #10928

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r11986 r12007  
    13711371    die();
    13721372    break;
     1373case 'set-post-thumbnail':
     1374    $post_id = intval( $_POST['post_id'] );
     1375    if ( !current_user_can( 'edit_post', $post_id ) )
     1376        die( '-1' );
     1377    $thumbnail_id = intval( $_POST['thumbnail_id'] );
     1378    if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
     1379        $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
     1380        if ( !empty( $thumbnail_html ) ) {
     1381            update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id );
     1382            die( _wp_post_thumbnail_html( $thumbnail_id ) );
     1383        }
     1384    }
     1385    die( '0' );
    13731386default :
    13741387    do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset for help on using the changeset viewer.