diff --git a/wp-includes/post.php b/wp-includes/post.php index a78b266a12..72d9d07bf1 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -6071,7 +6071,7 @@ function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) { * * @since 2.1.0 * - * @param int $attachment_id Attachment post ID. Defaults to global $post. + * @param int $attachment_id Attachment post ID. Default 0. * @param bool $unfiltered Optional. If true, filters are not run. Default false. * @return array|false { * Attachment metadata. False on failure. @@ -6087,6 +6087,16 @@ function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) { function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) { $attachment_id = (int) $attachment_id; + if ( ! $attachment_id ) { + $post = get_post(); + + if ( ! $post ) { + return false; + } + + $attachment_id = $post->ID; + } + $data = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); if ( ! $data ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 9b90ab944a..cd664e2930 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6.1-alpha-50038'; +$wp_version = '5.6.1-alpha-50040'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.