Make WordPress Core

Ticket #17895: 17895-set-change.diff

File 17895-set-change.diff, 696 bytes (added by CoenJacobs, 13 years ago)

Or changed the set_post_thumbnail() function, passing 0 as the new id to remove.

  • post.php

     
    51795179function set_post_thumbnail( $post, $thumbnail_id ) {
    51805180        $post = get_post( $post );
    51815181        $thumbnail_id = absint( $thumbnail_id );
    5182         if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
     5182        if ( $post && $thumbnail_id == 0 ) {
     5183                delete_post_meta( $post->ID, '_thumbnail_id' );
     5184        } else if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
    51835185                $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
    51845186                if ( ! empty( $thumbnail_html ) ) {
    51855187                        update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );