WordPress.org

Make WordPress Core

#26587 closed defect (bug) (fixed)

wp.media library argument post__not_in breaks the uploads

Reported by: ciantic Owned by: wonderboymusic
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.8
Component: Media Keywords: has-patch
Focuses: javascript Cc:

Description

  1. Open any page with media uploader, type in JavaScript console: wp.media({library : { post__not_in : [123]}}).open()
  1. Then try to upload a file.

Notice that the Select file button does not work, new uploads does not show the progress bar nor the item being uploaded in the attachment area.

However post__not_in itself works in wp_ajax_query_attachments correctly by filtering only given attachment ID's from the list.

Attachments (1)

26587.diff (883 bytes) - added by wonderboymusic 11 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 @wonderboymusic18 months ago

  • Focuses javascript added
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.9

Confirmed

comment:2 follow-up: @tlovett118 months ago

This bug is not related to the post__not_in property. Setting library to a JSON object containing any property except order or orderby results in this behavior.

Last edited 18 months ago by tlovett1 (previous) (diff)

comment:3 in reply to: ↑ 2 @nacin17 months ago

  • Milestone changed from 3.9 to Future Release

Replying to tlovett1:

This bug is not related to the post__not_in property. Setting library to a JSON object containing any property except order or orderby results in this behavior.

Sounds then like this is not a serious bug, but just incomplete API. Moving to future.

@wonderboymusic11 months ago

comment:4 @wonderboymusic11 months ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 4.1

26587.diff allows you to pass include and exclude to Query.get(), which are aliases for post__in and post__not_in.

Example usage:

wp.media({frame: 'post', library: {include: [414, 415]}}).open()
wp.media({frame: 'post', library: {include: 414}}).open()
wp.media({frame: 'post', library: {exclude: [414, 415]}}).open()
wp.media({frame: 'post', library: {exclude: 414}}).open()

All of the parsed props are aliases, include and exclude are in line with what we do elsewhere.

comment:5 @wonderboymusic10 months ago

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

In 29759:

Add two properties to media.model.Attachments.propmap: include and exclude, which are aliases for post__in and post__not_in.

This allows you to instantiate a library that includes and/or excludes specific attachments by passing a single ID or an array of IDs.

Example usage:

wp.media({frame: 'post', library: {include: [414, 415]}}).open()
wp.media({frame: 'post', library: {include: 414}}).open()
wp.media({frame: 'post', library: {exclude: [414, 415]}}).open()
wp.media({frame: 'post', library: {exclude: 414}}).open()

Fixes #26587.

Note: See TracTickets for help on using tickets.