#51396 closed defect (bug) (fixed)
[Media upload.php] Switch back from grid to list mode reopen the modal
Reported by: | Mista-Flo | Owned by: | antpb |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Media | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
Steps to reproduce:
- Go to the media library in grid mode (wp-admin/upload.php?mode=grid)
- Click on an item, you should have something like this in the URL :
wp-admin/upload.php?item=27&mode=grid
- Refresh the page
- Close the modal
- Switch to list mode
- Switch back to grid mode
- The modal is now opened with the previous item
This is due because the URL to switch between modes are generated in PHP src/wp-includes/media-template.php
, meaning the URL is set once and do not get updated if there are some dynamic changes in the page.
The code is:
<?php <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ); ?>" class="view-list"> <span class="screen-reader-text"><?php _e( 'List view' ); ?></span> </a> <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ); ?>" class="view-grid current" aria-current="page"> <span class="screen-reader-text"><?php _e( 'Grid view' ); ?></span> </a>
So we have to find a better way to handle this I guess, even if it's very edgecase.
I do not know all URL parameters you can have in this page, so I'm not sure about the solution, but I think we can just assume to reset any parameter when switching from one mode to another. If so, then we could stay in PHP and just print the admin_url of upload.php.
Attachments (1)
Change History (9)
#1
@
4 years ago
- Component changed from General to Media
- Focuses administration added
- Keywords has-patch added
- Version changed from trunk to 4.0
This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.
4 years ago
#3
@
4 years ago
Hi there!
51396.1.patch patch working fine for me.
Fix with PHP