Make WordPress Core


Ignore:
Timestamp:
02/09/2021 05:25:18 PM (4 years ago)
Author:
antpb
Message:

Media: Make adjacent_image_link() include alt text when returning an image.

When using the adjacent_image_link() function there is a condition that will return a linked image. Previously, the returned image was sent without alt attributes.

Now, adjacent_image_link() will include alt attributes of the image's title when an image is returned.

Props joedolson, Mista-Flo, sabernhardt.
Fixes #52387.

File:
1 edited

Legend:

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

    r50236 r50274  
    34423442        if ( isset( $attachments[ $k ] ) ) {
    34433443            $attachment_id = $attachments[ $k ]->ID;
    3444             $output        = wp_get_attachment_link( $attachment_id, $size, true, false, $text );
     3444            $attr          = array( 'alt' => get_the_title( $attachment_id ) );
     3445            $output        = wp_get_attachment_link( $attachment_id, $size, true, false, $text, $attr );
    34453446        }
    34463447    }
Note: See TracChangeset for help on using the changeset viewer.