Make WordPress Core

Opened 5 months ago

Last modified 3 months ago

#39004 accepted enhancement

Alt attributes should be searchable in media library

Reported by: joedolson Owned by: joedolson
Milestone: 4.8 Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords: needs-testing needs-unit-tests
Focuses: accessibility, administration Cc:


The alt attribute is intended to be the alternative replacement value for an image. As such, if you're managing an image library correctly, it would be entirely reasonable that most images would have an alt attribute but no caption or description. However, this means that your only searchable field is the image title.

Attachments (3)

39004.patch (1.0 KB) - added by rommelxcastro 5 months ago.
39004.1.patch (1.0 KB) - added by rommelxcastro 5 months ago.
fixes query
39004.2.patch (2.0 KB) - added by rommelxcastro 5 months ago.
function name refactor

Download all attachments as: .zip

Change History (14)

#1 @joedolson
5 months ago

See #22744 as a model for doing this.

#2 @joedolson
5 months ago

  • Owner set to joedolson
  • Status changed from new to accepted

#3 @joedolson
5 months ago

  • Version set to 3.0

Setting version to 3.0; but this has probably been the case from the beginning. I'm just copycatting @johnbillion. ;)

#4 @joedolson
5 months ago

  • Milestone changed from Awaiting Review to 4.8

#5 @rommelxcastro
5 months ago

  • Keywords needs-testing added; needs-patch removed

First patch added, I will add another one since probably the function name needs to be renamed to clarify it doesn't just searches by title

5 months ago

fixes query

5 months ago

function name refactor

#6 @rommelxcastro
5 months ago

  • Keywords 2nd-opinion added

39004.2.patch has the same query as 39004.1.patch, but changes the function name to meta to reflects it searches by meta.

#7 @rommelxcastro
5 months ago

  • Keywords needs-unit-tests added

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

5 months ago

#9 @joemcgill
5 months ago

Take note of #39092. We will probably want to do something similar for this.

#10 @joemcgill
4 months ago

  • Keywords dev-feedback 2nd-opinion removed

Related: #39358. We'll need to be aware of query performance concerns introduced in [38625] / #22744 before finalizing the approach here.

Setting aside performance concerns for the moment, 39004.2.patch looks like a good initial approach. Thanks @rommelxcastro. We may need to handle some backwards compatibility for anyone who has decided to do something like: remove_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); or if someone is calling that function directly to apply the filter to other query cases.

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

3 months ago

Note: See TracTickets for help on using tickets.