Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php	(revision 23294)
+++ wp-includes/template.php	(working copy)
@@ -306,29 +306,29 @@
  * 'attachment.php' is checked and returned.
  *
  * Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and
- * finally 'text_plain.php'.
+ * finally 'text-plain.php'.
  *
  * @since 2.0.0
  *
  * @return string
  */
 function get_attachment_template() {
-	global $posts;
+	$attachment = get_queried_object();
 
-	if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) {
-		$type = explode( '/', $posts[0]->post_mime_type );
+	$templates = array();
 
+	if ( $attachment ) {
+		$type = explode( '/', $attachment->post_mime_type );
+
 		if ( ! empty( $type ) ) {
-			if ( $template = get_query_template( $type[0] ) )
-				return $template;
-			elseif ( $template = get_query_template( $type[1] ) )
-				return $template;
-			elseif ( $template = get_query_template( "$type[0]_$type[1]" ) )
-				return $template;
+			$templates[] = "{$type[0]}-{$type[1]}.php";
+			$templates[] = "{$type[1]}.php";
+			$templates[] = "{$type[0]}.php";
 		}
 	}
+	$templates[] = 'attachment.php';
 
-	return get_query_template( 'attachment' );
+	return get_query_template( 'attachment', $templates );
 }
 
 /**
