Index: src/wp-includes/post-template.php
===================================================================
--- src/wp-includes/post-template.php	(revision 28551)
+++ src/wp-includes/post-template.php	(working copy)
@@ -1446,48 +1446,66 @@
  * Retrieve an attachment page link using an image or icon, if possible.
  *
  * @since 2.5.0
- * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
  *
- * @param int|WP_Post $id Optional. Post ID or post object.
- * @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 array $args {
+ *     An array of arguments. Optional.
+ *
+ *     @type int|WP_Post $ID Optional.                Post ID or post object.
+ *     @type string      $image_size                  Optional, default is 'thumbnail'. Size of image, either array or string.
+ *     @type bool        $include_permalink_in_anchor Optional, default is false. Whether to add permalink to the anchor.
+ *     @type bool        $display_media_icon          Optional, default is false. Whether to include icon.
+ *     @type string|bool $link_content                Optional, default is false. If string, then will be link text.
+ * }
  * @return string HTML content.
  */
-function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
-	$id = intval( $id );
+function wp_get_attachment_link( $args = array() ) {
+	// Backward compatibility. Convert deprecated function parameters into an options hash.
+	if ( ! is_array( $args ) || func_num_args() > 1 ) {
+		_deprecated_argument( __FUNCTION__, '4.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.' ), __FUNCTION__, __FILE__ ) );
+
+		$old_parameters = array( 'ID', 'image_size', 'include_permalink_in_anchor', 'display_media_icon', 'link_content' );
+		$func_args = func_get_args();
+		$args = array_combine( array_slice( $old_parameters, 0, count( $func_args ) ), $func_args );
+	}
+	$args = wp_parse_args( $args, array(
+		'ID'                          => 0,
+		'image_size'                  => 'thumbnail',
+		'include_permalink_in_anchor' => false,
+		'display_media_icon'          => false,
+		'link_content'                => false,
+	) );
+
+	$id = intval( $args['ID'] );
 	$_post = get_post( $id );
 
 	if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
 		return __( 'Missing Attachment' );
 
-	if ( $permalink )
+	if ( $args['include_permalink_in_anchor'] )
 		$url = get_attachment_link( $_post->ID );
 
-	if ( $text )
-		$link_text = $text;
-	elseif ( $size && 'none' != $size )
-		$link_text = wp_get_attachment_image( $id, $size, $icon );
-	else
-		$link_text = '';
+	$link_content = '';
+	if ( $args['link_content'] )
+		$link_content .= $args['link_content'];
+	elseif ( $args['image_size'] && 'none' != $args['image_size'] )
+		$link_content .= wp_get_attachment_image( $id, $args['image_size'], $args['display_media_icon'] );
 
-	if ( trim( $link_text ) == '' )
-		$link_text = $_post->post_title;
+	if ( trim( $link_content ) == '' )
+		$link_content = $_post->post_title;
 
 	/**
 	 * Filter a retrieved attachment page link.
 	 *
 	 * @since 2.7.0
 	 *
-	 * @param string      $link_html The page link HTML output.
-	 * @param int         $id        Post ID.
-	 * @param string      $size      Image size. Default 'thumbnail'.
-	 * @param bool        $permalink Whether to add permalink to image. Default false.
-	 * @param bool        $icon      Whether to include an icon. Default false.
-	 * @param string|bool $text      If string, will be link text. Default false.
+	 * @param string      $link_html                           The page link HTML output.
+	 * @param int         $id                                  Post ID.
+	 * @param string      $args['image_size']                  Image size. Default 'thumbnail'.
+	 * @param bool        $args['include_permalink_in_anchor'] Whether to add permalink in the anchor. Default false.
+	 * @param bool        $args['display_media_icon']          Whether to include an icon. Default false.
+	 * @param string|bool $args['link_content']                Content of the anchor. Default false.
 	 */
-	return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
+	return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_content</a>", $id, $args['image_size'], $args['include_permalink_in_anchor'], $args['display_media_icon'], $args['link_content'] );
 }
 
 /**
