Make WordPress Core

Ticket #37658: 37658.diff

File 37658.diff, 1.3 KB (added by flixos90, 10 years ago)
  • src/wp-includes/post.php

     
    32603260        }
    32613261
    32623262        // Set or remove featured image.
    3263         if ( isset( $postarr['_thumbnail_id'] ) && ( post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type ) ) {
    3264                 $thumbnail_id = intval( $postarr['_thumbnail_id'] );
    3265                 if ( -1 === $thumbnail_id ) {
    3266                         delete_post_thumbnail( $post_ID );
    3267                 } else {
    3268                         set_post_thumbnail( $post_ID, $thumbnail_id );
     3263        if ( isset( $postarr['_thumbnail_id'] ) ) {
     3264                $thumbnail_support = post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type;
     3265                if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) {
     3266                        if ( wp_attachment_is( 'audio', $post_ID ) ) {
     3267                                $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' );
     3268                        } elseif ( wp_attachment_is( 'video', $post_ID ) ) {
     3269                                $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' );
     3270                        }
    32693271                }
     3272
     3273                if ( $thumbnail_support ) {
     3274                        $thumbnail_id = intval( $postarr['_thumbnail_id'] );
     3275                        if ( -1 === $thumbnail_id ) {
     3276                                delete_post_thumbnail( $post_ID );
     3277                        } else {
     3278                                set_post_thumbnail( $post_ID, $thumbnail_id );
     3279                        }
     3280                }
    32703281        }
    32713282
    32723283        if ( ! empty( $postarr['meta_input'] ) ) {