Add a 6th (!) attribute to wp_get_attachment_link() to allow aria-describedby to be added to gallery output.

Props joedolson, DrewAPicture, rianrietveld.
Fixes #27402.


git-svn-id: https://develop.svn.wordpress.org/trunk@29914 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-10-16 04:27:07 +00:00
parent 248fc182b8
commit 076c7e8902
2 changed files with 13 additions and 9 deletions

View File

@@ -1462,9 +1462,10 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $
* @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|string $attr Optional. Array or string of attributes.
* @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 );
@@ -1474,12 +1475,13 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals
if ( $permalink )
$url = get_attachment_link( $_post->ID );
if ( $text )
if ( $text ) {
$link_text = $text;
elseif ( $size && 'none' != $size )
$link_text = wp_get_attachment_image( $id, $size, $icon );
else
} elseif ( $size && 'none' != $size ) {
$link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
} else {
$link_text = '';
}
if ( trim( $link_text ) == '' )
$link_text = $_post->post_title;