Hook into backbone to add js to wp-admin -> media library?
I've enqueued a .js file on the "Media Library" page (upload.php). I need to hide and manipulate a few of the thumbnails on the page using JS only ( I'm not looking for workarounds ).
The elements on the page are being rendered by backbone and I have found no way so far to hook into it. In any window/document state, $('li.attachment').hide() function for example won't do it's job because of this.
I have tried going with the following piece of code, with no result so far, can't even debug the code because of unproperly hooking:
window.wp = window.wp || {};
( function( $, _ ) {
var media = wp.media,
Attachments = media.model.Attachments,
Query = media.model.Query,
original = {};
original.AttachmentsBrowser = {
manipulate: media.view.AttachmentsBrowser.prototype.manipulate
};
_.extend( media.view.AttachmentsBrowser.prototype, {
initialize: function() {
original.AttachmentsBrowser.initialize.apply( this, arguments );
},
manipulate: function() {
var options = this.options,
self = this,
i = 1;
original.AttachmentsBrowser.manipulate.apply( this, arguments );
console.log('got here'); // Not outputting a thing
}
});
Any ideas how I should go about it?
Thanks a lot in advance!
Topic backbone underscore media-library media wp-admin Wordpress
Category Web