Make WordPress Core

Opened 5 years ago

Last modified 4 years ago

#48236 new defect (bug)

Media attachment browser no longer provides id of attachment

Reported by: slebog's profile slebog Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.2.3
Component: Media Keywords: has-patch needs-refresh
Focuses: administration Cc:


This is a follow-up to #47458.

Issue #47458 removed the data-id attribute from the media attachment browser. This was a useful attribute, used by an (internal) plugin on our site to access the details of the currently displayed attachment. We used code similar to this to hook into the dialog:'ready', function() {
	var postid = $('.attachment-details').data('id'),
		details =;
	// do stuff with details

This functionality is now broken, and I can’t see another way to access the id of the attachment details being shown. (The item id in the query string is not reliable, as it’s not always updated in time, or at all.)

Could this useful attribute be restored? It doesn’t seem to affect the problem addressed in #47458 in any way.

Attachments (1)

48236.diff (601 bytes) - added by slebog 5 years ago.

Download all attachments as: .zip

Change History (13)

5 years ago

#1 @slebog
5 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Version set to 5.2.3

#3 @peterwilsoncc
5 years ago

  • Milestone changed from 5.3 to 5.2.4

Moving to the 5.2.4 milestone as this was introduced in a point release so ought to be back ported for sites affected by the auto update.

This ticket was mentioned in Slack in #core by marybaum. View the logs.

5 years ago

#5 @desrosj
5 years ago

  • Milestone changed from 5.2.4 to 5.2.5

Punting to 5.2.5 as 5.2.4 was just released.

#6 @desrosj
5 years ago

  • Keywords needs-testing added
  • Milestone changed from 5.2.5 to 5.4

Unfortunately, with the impending 5.3 RC1, time has run out for this one.

I am going to punt to 5.4 for now, but it can be moved up into a minor when ready.

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

4 years ago

#8 @audrasjb
4 years ago

  • Focuses accessibility removed

As per today's accessibility team bug scrub, it doesn't appear to be really related to accessibility focus.

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

4 years ago

#10 @afercia
4 years ago

  • Keywords needs-refresh added; needs-testing removed

Some history: The attachment details inherits from Attachment, which is a <li> element with several attributes:

	attributes: function() {
		return {
			'tabIndex':     0,
			'role':         'checkbox',
			'aria-label':   this.model.get( 'title' ),
			'aria-checked': false,
			'data-id':      this.model.get( 'id' )

Before [30483] / #30390 Attachment.Details inherited all those attributes, which was incorrect for this <div> element used in the media modal. The incorrect output was something like this:

	aria-label="{ alt or file name }"
	class="attachment-details save-ready"

[30483] reset most of them keeping just tabIndex and data-id.

Then, [45506] / #47458 removed all the attributes by using an empty object attributes: {}. The tabindex attribute was producing an unexpected tab stop on an unlabeled element. The data-id attribute was not used by core nor was documented anywhere or part of an official API, at least to my knowledge.

It it's something plugins are largely using, then it's certainly possible to consider to restore it. The important part is to avoid inheritance from Attachment otherwise this element will get again all the previous incorrect, unnecessary, HTML attributes.

48236.diff looks good to me except for:

  • there should be just one space before this.model.get( 'id' )
  • the comment should be updated accordingly, and explain why we're explicitly setting an attribute that's already inherited (we'd do this to reset the other attributes)

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

4 years ago

#12 @audrasjb
4 years ago

  • Milestone changed from 5.4 to Future Release


With 5.4 Beta 3 approaching and the Beta period reserved for bugs introduced during the cycle, this is being moved to Future Release. If any maintainer or committer feels this should be included or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.

Note: See TracTickets for help on using tickets.