Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#22514 closed enhancement (fixed)

Add a way to filter attachments in the media modal

Reported by: koopersmith's profile koopersmith Owned by: koopersmith's profile koopersmith
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords:
Focuses: Cc:

Description

As discussed in #20258.

Change History (12)

#1 @koopersmith
12 years ago

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

In 22712:

Media: Add filters to the media library. fixes #22514, see #21390.

#2 follow-up: @pavelevap
12 years ago

  • Cc pavelevap@… added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Great! But there are other problems:

1) String "Uploaded to this post" is not accurate - files can be uploaded also to Pages or CPT.

2) Default view should display files uploaded to post and not the whole media library? People usually want to work with uploaded files and there is no need to show them all files. If you want to show only related (uploaded) files, you have to select a filter. It is also change of current workflow for users, so there should be at least the chance to enable this filter by default with the help of some hook.

#3 in reply to: ↑ 2 @DrewAPicture
12 years ago

  • Cc xoodrew@… added

Replying to pavelevap:

Great! But there are other problems:

1) String "Uploaded to this post" is not accurate - files can be uploaded also to Pages or CPT.

Related: #19696. This may be a discussion for another day, but I wonder about something like this?

'uploadedToThisPost' => sprintf( __( 'Uploaded to this %s' ), strtolower( $post_type_object->labels->singular_name ) ),

A cursory check of posts vs pages vs a custom post type yielded good results for me.

#4 @nacin
12 years ago

Also, this should use:

  • get_post_mime_types() (we'll only be using the first item in each array, but it's the filter that is important).
  • get_available_post_mime_types(), to know what mime types are in use.

The available mime types can be intersected with get_post_mime_types() using wp_match_mime_types(). Using get_available_post_mime_types() is optional, given that we don't refresh the page and therefore couldn't easily account for files of a new type being uploaded. But, when new attachments are uploaded, we could see if their type is now available, and show them at that point. Huge bite of the apple, though.

#5 follow-up: @DrewAPicture
12 years ago

Expanding on comment:3, another option would be to introduce a filter and you could change the string to whatever you want. Again, similar in concept to #19696.

#6 in reply to: ↑ 5 @koopersmith
12 years ago

Replying to DrewAPicture:

Expanding on comment:3, another option would be to introduce a filter and you could change the string to whatever you want. Again, similar in concept to #19696.

We're one step ahead of you — check out the media_view_strings filter and #21092.

#7 @koopersmith
12 years ago

We should add page strings by default by checking is_post_type_hierarchical().

The dropdown should also use get_post_mime_types(). Intersecting those results with get_available_post_mime_types() would be nice, but not necessary.

#8 @nacin
12 years ago

[22735] was meant for this ticket. Handles hierarchical checks.

#9 @koopersmith
12 years ago

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

In 22743:

Media: Dynamically generate attachment filters using get_post_mime_types().

Moves get_post_mime_types() from wp-admin/includes/post.php to wp-includes/post.php.

fixes #22514, see #21390.

#10 follow-up: @pavelevap
12 years ago

Added filters does not show when you click "Choose a Featured Image"? Users usually want to select featured image from images uploaded (attached) to post.

#11 in reply to: ↑ 10 @koopersmith
12 years ago

Replying to pavelevap:

Added filters does not show when you click "Choose a Featured Image"? Users usually want to select featured image from images uploaded (attached) to post.

Yup. Those were next.

#12 @koopersmith
12 years ago

In 22745:

Media: Add filters for image-only libraries. see #22514, #21390.

Note: See TracTickets for help on using tickets.