Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 22098)
+++ wp-includes/post-template.php	(working copy)
@@ -1138,17 +1138,21 @@
  *
  * @since 2.5.0
  * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
+ * @uses apply_filters() Calls 'wp_get_attachment_link_attributes' hook on attributes array
+ * @uses wp_parse_args() Merges the defaults with those defined by $args and allows for strings.
  *
  * @param int $id Optional. Post ID.
  * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
  * @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 string|array $attr Optional, default is empty string.
  * @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 );
+	$attr_html = '';
 
 	if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
 		return __( 'Missing Attachment' );
@@ -1168,7 +1172,19 @@
 	if ( trim( $link_text ) == '' )
 		$link_text = $_post->post_title;
 
-	return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon, $text );
+	$default_attr = array(
+		'href'  => $url,
+		'title' => $post_title,
+	);
+
+	$attr = wp_parse_args($attr, $default_attr);
+	$attr = apply_filters( 'wp_get_attachment_link_attributes', $attr, $_post );
+	$attr = array_map( 'esc_attr', $attr );
+
+	foreach ( $attr as $name => $value ) {
+		$attr_html .= " {$name}=\"{$value}\"";
+	}
+	return apply_filters( 'wp_get_attachment_link', "<a $attr_html>$link_text</a>", $id, $size, $permalink, $icon, $text );
 }
 
 /**
