Make WordPress Core

Ticket #41726: 41726.diff

File 41726.diff, 519 bytes (added by mrasharirfan, 6 years ago)

Added extra parameter to return WP_Error object if any error occurs.

  • wp-admin/includes/media.php

     
    378378        unset( $attachment['ID'] );
    379379
    380380        // Save the data
    381         $id = wp_insert_attachment($attachment, $file, $post_id);
     381        $id = wp_insert_attachment( $attachment, $file, $post_id, true );
    382382        if ( !is_wp_error($id) ) {
    383383                wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
    384384        }