Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 21780)
+++ wp-includes/media.php	(working copy)
@@ -817,7 +817,7 @@
 	}
 
 	if ( !empty($include) ) {
-		$include = preg_replace( '/[^0-9,]+/', '', $include );
+		$include = wp_parse_id_list( $include );
 		$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
 
 		$attachments = array();
@@ -825,7 +825,7 @@
 			$attachments[$val->ID] = $_attachments[$key];
 		}
 	} elseif ( !empty($exclude) ) {
-		$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
+		$exclude = wp_parse_id_list( $exclude );
 		$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
 	} else {
 		$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
