WordPress.org

Make WordPress Core

Ticket #27402: 27402.2.patch

File 27402.2.patch, 2.4 KB (added by joedolson, 7 years ago)

Sets aria-describedby directly to img

  • wp-includes/media.php

     
    962962
    963963        $i = 0;
    964964        foreach ( $attachments as $id => $attachment ) {
     965                $attr = ( trim($attachment->post_excerpt) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
     966               
    965967                if ( ! empty( $link ) && 'file' === $link )
    966                         $image_output = wp_get_attachment_link( $id, $size, false, false );
     968                        $image_output = wp_get_attachment_link( $id, $size, false, false, false, $attr );
    967969                elseif ( ! empty( $link ) && 'none' === $link )
    968                         $image_output = wp_get_attachment_image( $id, $size, false );
     970                        $image_output = wp_get_attachment_image( $id, $size, false, $attr );
    969971                else
    970                         $image_output = wp_get_attachment_link( $id, $size, true, false );
     972                        $image_output = wp_get_attachment_link( $id, $size, true, false, false, $attr );
    971973
    972974                $image_meta  = wp_get_attachment_metadata( $id );
    973975
     
    982984                        </{$icontag}>";
    983985                if ( $captiontag && trim($attachment->post_excerpt) ) {
    984986                        $output .= "
    985                                 <{$captiontag} class='wp-caption-text gallery-caption'>
     987                                <{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
    986988                                " . wptexturize($attachment->post_excerpt) . "
    987989                                </{$captiontag}>";
    988990                }
  • wp-includes/post-template.php

     
    11991199 * @param bool $permalink Optional, default is false. Whether to add permalink to image.
    12001200 * @param bool $icon Optional, default is false. Whether to include icon.
    12011201 * @param string|bool $text Optional, default is false. If string, then will be link text.
     1202 * @param mixed $attr Optional, attributes for the image markup.
    12021203 * @return string HTML content.
    12031204 */
    1204 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
     1205function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
    12051206        $id = intval( $id );
    12061207        $_post = get_post( $id );
    12071208
     
    12161217        if ( $text )
    12171218                $link_text = $text;
    12181219        elseif ( $size && 'none' != $size )
    1219                 $link_text = wp_get_attachment_image( $id, $size, $icon );
     1220                $link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
    12201221        else
    12211222                $link_text = '';
    12221223