Skip to content

Instantly share code, notes, and snippets.

@tridungpham
Created August 13, 2013 08:30
Show Gist options
  • Save tridungpham/6219049 to your computer and use it in GitHub Desktop.
Save tridungpham/6219049 to your computer and use it in GitHub Desktop.
Select the selected attachment when open gallery media.
// open
_media.frame.on('open',function() {
// add class
_media.frame.$el.closest('.media-modal').addClass('acf-media-modal acf-expanded');
//console.log( _media.frame.state() );
// set selection
var selection = _media.frame.state().get('selection'),
attachment = wp.media.attachment( id );
attachment.fetch();
selection.add( attachment );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment