Make WordPress Core

Ticket #52603: 52603.2.diff

File 52603.2.diff, 1.2 KB (added by SergeyBiryukov, 4 years ago)
  • src/wp-admin/includes/image.php

     
    470470 *
    471471 * @param int    $attachment_id Attachment Id to process.
    472472 * @param string $file          Filepath of the Attached image.
    473  * @return mixed Metadata for attachment.
     473 * @return array Metadata for attachment.
    474474 */
    475475function wp_generate_attachment_metadata( $attachment_id, $file ) {
    476476        $attachment = get_post( $attachment_id );
     
    490490                $support  = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
    491491        }
    492492
     493        if ( ! is_array( $metadata ) ) {
     494                $metadata = array();
     495        }
     496
    493497        if ( $support && ! empty( $metadata['image']['data'] ) ) {
    494498                // Check for existing cover.
    495499                $hash   = md5( $metadata['image']['data'] );
     
    613617        }
    614618
    615619        // Remove the blob of binary data from the array.
    616         if ( $metadata ) {
    617                 unset( $metadata['image']['data'] );
    618         }
     620        unset( $metadata['image']['data'] );
    619621
    620622        /**
    621623         * Filters the generated attachment meta data.