WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#30584 closed defect (bug) (fixed)

Media Manager - Grid view does not respect taxonomy URL parameters.

Reported by: Phyrax Owned by: wonderboymusic
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.0.1
Component: Media Keywords: has-patch
Focuses: javascript, administration Cc:

Description

The title pretty much explains the issue I've found. Current setup is as follows:

  • XAMPP v3.1.0 Beta 6
  • Wordpress 4.0.1
  • No plugins active ( no mu-plugins either )
  • Twenty Fourteen Theme v1.2
  • PHP 5.4.7
  • MySQL 5.5.27

Steps to reproduce

First and foremost you'll need to add this to your theme/plugin functions file:

Register taxonomy to attachments:

add_action( 'init', 'jw_tax' );
function jw_tax(){
        register_taxonomy( 'media_cats', 'attachment', array(
                'label' => __( 'Media Categories', 'jw' ),
                'hierarchical' => true,
        ));
}

Please excuse the neglected count callback to update attachment taxonomy counts.

  1. Upload an attachment via Media > Add New ( or use an existing image )
  2. Edit the attachment and add a term to it under the new Media Categories taxonomy and save.
  3. Upload a few extra images, but do not attach them to the taxonomy.
  4. Once saved, go to Media > Media Categories ( new taxonomy ), and click on the count number for that term
    1. It shows zero due to me not setting the count callback, ignore that as it's unrelated.
  5. You are then redirected to the media library with the url paramter. ( example: http://localhost/wordpress/wp-admin/upload.php?media_cats=testing&post_type=attachment )
    1. At this point if you're in list view, the library respects the media_cats url parameter and loads only the image you assigned to the term name
    2. If you switch to grid view, the grid shows all images and ignores the URL parameter.

NOTES

Regardless of switching between list and grid view, either before ( via user profile data ) or after the redirect to the library upon clicking the count number, grid view is just not responding to the URL parameters.

Essentially if the user is using the grid view, by default, there is no way for users to sort the library by taxonomy data. In lieu of that, we have used a plugin that adds a dropdown to the media toolbar for taxonomy stuff. This plugin, however, still does not help with the above issue of the grid view and URL parameters, but should provide a good starting point for someone.

The Plugin: https://wordpress.org/plugins/enhanced-media-library/

Attachments (1)

30584.diff (5.5 KB) - added by wonderboymusic 4 years ago.

Download all attachments as: .zip

Change History (5)

@wonderboymusic
4 years ago

#1 @wonderboymusic
4 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.2

Thanks for the report, this was a fun one

#2 @wonderboymusic
4 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 31037:

Respect query vars for taxonomies passed as URL parameters when in grid mode of Media Library.

Fixes #30584.

#3 @wonderboymusic
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I broke something

#4 @wonderboymusic
4 years ago

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

In 31041:

After [31037], ensure that the library is passed as a map to the Media Grid instance. Remove useless query vars.

Fixes #30584.

Note: See TracTickets for help on using tickets.