Index: src/wp-admin/includes/media.php
===================================================================
--- src/wp-admin/includes/media.php	(revision 27125)
+++ src/wp-admin/includes/media.php	(working copy)
@@ -2636,10 +2636,14 @@
 	<?php
 	elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ):
 
+		maybe_regenerate_attachment_metadata( $post );
+
 		echo wp_audio_shortcode( array( 'src' => $att_url ) );
 
 	elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ):
 
+		maybe_regenerate_attachment_metadata( $post );
+
 		$meta = wp_get_attachment_metadata( $attachment_id );
 		$w = ! empty( $meta['width'] ) ? min( $meta['width'], 600 ) : 0;
 		$h = 0;
Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 27125)
+++ src/wp-includes/media.php	(working copy)
@@ -2194,3 +2194,26 @@
 	$gallery = get_post_gallery( $post, false );
 	return empty( $gallery['src'] ) ? array() : $gallery['src'];
 }
+
+/**
+ * If an attachment is missing its metadata, try to regenerate it
+ *
+ * @param post $attachment Post object.
+ */
+function maybe_regenerate_attachment_metadata( $attachment ) {
+	if ( empty( $attachment ) || ( empty( $attachment->ID ) || ! $attachment_id = (int) $attachment->ID ) ) {
+		return;
+	}
+
+	$file = get_attached_file( $attachment_id );
+	$meta = wp_get_attachment_metadata( $attachment_id );
+	if ( empty( $meta ) && file_exists( $file ) ) {
+		$_meta = get_post_meta( $attachment_id );
+		$regeneration_lock = 'wp_regenerating_' . $attachment_id;
+		if ( ! array_key_exists( '_wp_attachment_metadata', $_meta ) && ! get_transient( $regeneration_lock ) ) {
+			set_transient( $regeneration_lock, $file );
+			wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
+			delete_transient( $regeneration_lock );
+		}
+	}
+}
\ No newline at end of file
