Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created July 17, 2017 12:43
Show Gist options
  • Save lgedeon/34ec75107085742a95f348affbc452e3 to your computer and use it in GitHub Desktop.
Save lgedeon/34ec75107085742a95f348affbc452e3 to your computer and use it in GitHub Desktop.
Experimental code (not yet working) to make items in the media library non-selectable.
//wp.media.view.Modal.prototype: open, ready
( function ($) {
var $attachments = $('.attachments').children(),
blocked = [ 1, 2, 12, 4593 ];
wp.media.events.on( 'open', function( arguments ) {
alert('event fired')
});
$attachments.each( function(index) {
var $this = $(this),
id = $this.data("id");
if ( -1 !== blocked.indexOf( id ) ) {
$this.children( '.js--select-attachment' ).removeClass( 'js--select-attachment' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment