Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#26587 closed defect (bug) (fixed)

wp.media library argument post__not_in breaks the uploads

Reported by: ciantic's profile ciantic Owned by: wonderboymusic's profile 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 10 years ago.

Download all attachments as: .zip

Change History (6)

#1 @wonderboymusic
10 years ago

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

Confirmed

#2 follow-up: @tlovett1
10 years 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 10 years ago by tlovett1 (previous) (diff)

#3 in reply to: ↑ 2 @nacin
10 years 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.

#4 @wonderboymusic
10 years 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.

#5 @wonderboymusic
10 years 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.