#53419 closed defect (bug) (fixed)
Media: Links to individual media items don't work
Reported by: | ryelle | Owned by: | joedolson |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch commit |
Focuses: | javascript | Cc: |
Description
It looks like links to individual media items have stopped working after r51145/#50105.
The expected behavior, on beta1:
- Go to Media, make sure you're in grid view
- Click a media
- The attachment modal opens, and the URL updated to something like
/wp-admin/upload.php?item=7
- You can reload the page, the URL stays the same, and the same attachment modal opens
In trunk or beta2:
- The attachment modal opens on click, but does not change the URL.
- Going directly to
/wp-admin/upload.php?item=7
does not open the attachment.
Attachments (2)
Change History (13)
This ticket was mentioned in PR #1381 on WordPress/wordpress-develop by adamsilverstein.
3 years ago
#1
- Keywords has-patch added
#2
@
3 years ago
Hey @ryelle :} thanks for catching and raising this issue, and especially for identifying the offending commit!
This is caused by our changing the deferred resolution to use the (typical) deferred.jqXHR
instead of core's setting of this
which causes us to not have access to the response headers in the collection's parse
method (in attachments.js).
This tricky part is we need access to both the collection and the request jqxhr to pull the collection totals from the header response and set them in the collection.
In 53419.diff I moved the logic out of the custom fetch method we added into wp.ajax.send where we have access to both the collection and the actual xhr response. The only addition to the existing code is a check to make sure this is a media request and capturing the context (the attachments collection) before the done handler so we can set the attachment count.
Can you please give it a test and confirm this corrects the issue you were seeing? It does in my testing.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 years ago
#5
@
3 years ago
I was able to reproduce the issue on a site running nightly. I applied the patch to my local and it seems to restore the behavior of appending the item id on click allowing a refresh to re-open the modal.
Looks good to me, but I'm happy to wait for reporter-feedback.
Trac ticket: https://core.trac.wordpress.org/ticket/53419