From 5f2d089fb3fc2d66b0ac7feefe44a2d40bc441c8 Mon Sep 17 00:00:00 2001 From: Anthony Burchell Date: Tue, 9 Feb 2021 17:25:18 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@50274 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index f02f5f8d6b..349bcbae1d 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -3441,7 +3441,8 @@ function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) if ( isset( $attachments[ $k ] ) ) { $attachment_id = $attachments[ $k ]->ID; - $output = wp_get_attachment_link( $attachment_id, $size, true, false, $text ); + $attr = array( 'alt' => get_the_title( $attachment_id ) ); + $output = wp_get_attachment_link( $attachment_id, $size, true, false, $text, $attr ); } }