WordPress.org

Make WordPress Core

Opened 4 weeks ago

Closed 3 weeks ago

#52387 closed defect (bug) (fixed)

adjacent_image_link returns a link with no accessible text

Reported by: joedolson Owned by: antpb
Milestone: 5.7 Priority: normal
Severity: normal Version: 2.5
Component: Media Keywords: has-patch needs-testing
Focuses: accessibility Cc:

Description

The function adjacent_image_link(), used by previous_image_link() and next_image_link(), either returns a text link (if the $text parameter has a value) or a linked image. If the value returned is a linked image, the image is returned with no alt attribute, resulting in an empty link.

Attachments (1)

52387.diff (572 bytes) - added by joedolson 4 weeks ago.
Pass alt attribute with img title.

Download all attachments as: .zip

Change History (12)

@joedolson
4 weeks ago

Pass alt attribute with img title.

#1 @joedolson
4 weeks ago

Patch uses the image title, on two grounds:

1) The image title will always be present, where the alt attribute is not.
2) The image title represents the target of the link, where the alt attribute represents the image itself.

This ticket was mentioned in Slack in #themereview by joedolson. View the logs.


4 weeks ago

#3 @joedolson
4 weeks ago

  • Keywords has-patch needs-testing added; needs-patch removed

This ticket was mentioned in Slack in #core-media by joedolson. View the logs.


4 weeks ago

#5 @antpb
4 weeks ago

  • Owner set to antpb

This patch looks good. Will test and get this in for 5.7 alpha.

#6 @Mista-Flo
4 weeks ago

Code looks good, it seems there is no unit test related to that function, so I guess it's ok.

It would be nice to provide steps to test the current patch.

#7 @joedolson
4 weeks ago

1) Upload a minimum of three images in your test environment.
2) In one of the core themes that uses the functions previous_image_link and next_image_link (I used Twenty Twelve), edit image.php so that the function is called using an image, rather than text: previous_image_link( 'thumbnail', false )
3) View an image attachment page.

Before patch: Image thumbnails are shown representing the previous and next images; these images have no alt attribute.

After patch: Image thumbnails are shown with an alt attribute containing the title field for the image.

(There are no core theme uses of the function that call it in the thumbnail mode as far as I can find.)

#8 @sabernhardt
4 weeks ago

  • Milestone changed from Awaiting Review to 5.7

I tested with the Responsive theme, which has thumbnail navigation. Each of the linked previous and next images has alt text that matches the heading shown on the target image's attachment page.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


3 weeks ago

This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.


3 weeks ago

#11 @antpb
3 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 50274:

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.

Note: See TracTickets for help on using tickets.