Make WordPress Core

Opened 2 years ago

Closed 15 months ago

#54824 closed defect (bug) (fixed)

Hide "view" link from Media Library List Mode if empty string passed to attachment_link

Reported by: oh_hello's profile oh_hello Owned by: joedolson's profile joedolson
Milestone: 6.2 Priority: normal
Severity: normal Version: 5.6
Component: Media Keywords: has-patch commit
Focuses: accessibility Cc:

Description

As of WP 5.6.0, an empty string can be passed to attachment_link which will disable the view attachment page link on the media modal. That's great. Ref: https://developer.wordpress.org/reference/hooks/attachment_link/.

However, there's another link that should also be disabled in this scenario.

That's the "View" link that appears when hovering over a media item when browsing the Media Library in "List Mode" instead of "Grid Mode".

Currently, that "View" link is just empty. The code generated is:

<a href="" aria-label="View “title of media item”" rel="bookmark">View</a>

Ideally that "View" link would be removed entirely.

Attachments (5)

view-link-media-library.png (107.1 KB) - added by oh_hello 2 years ago.
Screenshot of the "view" link being referenced.
54824.diff (2.0 KB) - added by iqbalrony 17 months ago.
Here is the patch with the fixed code.
54824.2.diff (2.0 KB) - added by iqbalrony 17 months ago.
Here is the patch with the fixed code.
Screenshot 2023-02-03 154417.jpg (47.8 KB) - added by joedolson 15 months ago.
Before patch: view link, empty href.
Screenshot 2023-02-03 154547.jpg (13.1 KB) - added by joedolson 15 months ago.
No view link after patch

Download all attachments as: .zip

Change History (16)

@oh_hello
2 years ago

Screenshot of the "view" link being referenced.

#1 @joedolson
17 months ago

  • Focuses accessibility added
  • Milestone changed from Awaiting Review to 6.2
  • Owner set to joedolson
  • Status changed from new to accepted
  • Version set to 5.6

@iqbalrony
17 months ago

Here is the patch with the fixed code.

@iqbalrony
17 months ago

Here is the patch with the fixed code.

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


16 months ago

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


15 months ago

#4 @Mista-Flo
15 months ago

  • Keywords has-patch needs-testing added

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


15 months ago

#6 @joedolson
15 months ago

  • Keywords needs-testing removed

Tested by adding filter

add_filter( 'attachment_link', function() use ($link) {
     return '';
});

Before patch: view link present, empty URL.

After patch: no view link.

Screenshots coming.

@joedolson
15 months ago

Before patch: view link, empty href.

@joedolson
15 months ago

No view link after patch

#7 @joedolson
15 months ago

  • Keywords commit added

This ticket was mentioned in PR #3986 on WordPress/wordpress-develop by @joedolson.


15 months ago
#8

Test changes to remove list table link when attachment link is filter to empty value.

Trac ticket: https://core.trac.wordpress.org/ticket/54824

#11 @joedolson
15 months ago

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

This was closed in r55218, but didn't get auto-closed.

Media: Hide 'view' link if empty string passed to attachment_link.

Fix empty href attribute on 'View' link when the attachment_link filter is used to hide attachment pages.

Props oh_hello, iqbalrony.
Fixes #54824.
Note: See TracTickets for help on using tickets.