Make WordPress Core

Changeset 29914


Ignore:
Timestamp:
10/16/2014 04:27:07 AM (10 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r29837 r29914  
    10571057    $i = 0;
    10581058    foreach ( $attachments as $id => $attachment ) {
     1059       
     1060        $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
    10591061        if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) {
    1060             $image_output = wp_get_attachment_link( $id, $atts['size'], false, false );
     1062            $image_output = wp_get_attachment_link( $id, $atts['size'], false, false, $attr );
    10611063        } elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) {
    1062             $image_output = wp_get_attachment_image( $id, $atts['size'], false );
     1064            $image_output = wp_get_attachment_image( $id, $atts['size'], false, $attr );
    10631065        } else {
    1064             $image_output = wp_get_attachment_link( $id, $atts['size'], true, false );
     1066            $image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr );
    10651067        }
    10661068        $image_meta  = wp_get_attachment_metadata( $id );
     
    10771079        if ( $captiontag && trim($attachment->post_excerpt) ) {
    10781080            $output .= "
    1079                 <{$captiontag} class='wp-caption-text gallery-caption'>
     1081                <{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
    10801082                " . wptexturize($attachment->post_excerpt) . "
    10811083                </{$captiontag}>";
  • trunk/src/wp-includes/post-template.php

    r29429 r29914  
    14631463 * @param bool $icon Optional, default is false. Whether to include icon.
    14641464 * @param string|bool $text Optional, default is false. If string, then will be link text.
     1465 * @param array|string $attr Optional. Array or string of attributes.
    14651466 * @return string HTML content.
    14661467 */
    1467 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
     1468function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
    14681469    $id = intval( $id );
    14691470    $_post = get_post( $id );
     
    14751476        $url = get_attachment_link( $_post->ID );
    14761477
    1477     if ( $text )
     1478    if ( $text ) {
    14781479        $link_text = $text;
    1479     elseif ( $size && 'none' != $size )
    1480         $link_text = wp_get_attachment_image( $id, $size, $icon );
    1481     else
     1480    } elseif ( $size && 'none' != $size ) {
     1481        $link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
     1482    } else {
    14821483        $link_text = '';
     1484    }
    14831485
    14841486    if ( trim( $link_text ) == '' )
Note: See TracChangeset for help on using the changeset viewer.