[wp-trac] [WordPress Trac] #34465: When Excluding Attachments, Media Modal Browser Doesn't Update on Uploads
WordPress Trac
noreply at wordpress.org
Mon Dec 7 09:17:37 UTC 2015
#34465: When Excluding Attachments, Media Modal Browser Doesn't Update on Uploads
-------------------------------------------+------------------------------
Reporter: Funkatronic | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 4.0
Severity: normal | Resolution:
Keywords: has-screenshots needs-testing | Focuses: ui
-------------------------------------------+------------------------------
Comment (by nikolov.tmw):
I found the root of the issue in `Query.initialize()`. If you look at the
end of the function( https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/js/media-models.js#L1176 ), you'll see this:
{{{
// Observe the central `wp.Uploader.queue` collection to watch for
// new matches for the query.
//
// Only observe when a limited number of query args are set. There
// are no filters for other properties, so observing will result in
// false positives in those queries.
allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type',
'post_parent' ];
if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed
).isEmpty().value() ) {
this.observe( wp.Uploader.queue );
}
}}}
If I add 'author' to the `allowed` array, it works as expected.
I understand why it was implemented(since there's only a handful of
filters in `this.filters` defined), however I've been struggling to find a
way to override this functionality. I've tried extending multiple classes
in order to get past this limitation, but with no success so far(it could
be just my poor OOP JS skills though).
I feel like there should be an easier way to accomplish the usage of
additional query parameters, without having to extend many classes just to
override a bit of functionality. Perhaps optional parameters to the
`wp.media()` function?
On a side note - it's worth noting, that in order to implement additional
query parameters, you also might have to hook to the
'ajax_query_attachments_args' filter, since only certain query params are
allowed by default.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34465#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list