Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 27483)
+++ wp-includes/media.php	(working copy)
@@ -962,12 +962,14 @@
 
 	$i = 0;
 	foreach ( $attachments as $id => $attachment ) {
+		$attr = ( trim($attachment->post_excerpt) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
+		
 		if ( ! empty( $link ) && 'file' === $link )
-			$image_output = wp_get_attachment_link( $id, $size, false, false );
+			$image_output = wp_get_attachment_link( $id, $size, false, false, false, $attr );
 		elseif ( ! empty( $link ) && 'none' === $link )
-			$image_output = wp_get_attachment_image( $id, $size, false );
+			$image_output = wp_get_attachment_image( $id, $size, false, $attr );
 		else
-			$image_output = wp_get_attachment_link( $id, $size, true, false );
+			$image_output = wp_get_attachment_link( $id, $size, true, false, false, $attr );
 
 		$image_meta  = wp_get_attachment_metadata( $id );
 
@@ -982,7 +984,7 @@
 			</{$icontag}>";
 		if ( $captiontag && trim($attachment->post_excerpt) ) {
 			$output .= "
-				<{$captiontag} class='wp-caption-text gallery-caption'>
+				<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
 				" . wptexturize($attachment->post_excerpt) . "
 				</{$captiontag}>";
 		}
Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 27483)
+++ wp-includes/post-template.php	(working copy)
@@ -1199,9 +1199,10 @@
  * @param bool $permalink Optional, default is false. Whether to add permalink to image.
  * @param bool $icon Optional, default is false. Whether to include icon.
  * @param string|bool $text Optional, default is false. If string, then will be link text.
+ * @param mixed $attr Optional, attributes for the image markup.
  * @return string HTML content.
  */
-function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
+function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
 	$id = intval( $id );
 	$_post = get_post( $id );
 
@@ -1216,7 +1217,7 @@
 	if ( $text )
 		$link_text = $text;
 	elseif ( $size && 'none' != $size )
-		$link_text = wp_get_attachment_image( $id, $size, $icon );
+		$link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
 	else
 		$link_text = '';
 
