Created
December 3, 2012 01:46
-
-
Save koop/4192094 to your computer and use it in GitHub Desktop.
Query all attachments uploaded to a post.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build a query for all attachments uploaded to a post. | |
var gallery = wp.media.query({ uploadedTo: postId }); | |
// Run the query. | |
// This returns a promise (like $.ajax) so you can do things when it completes. | |
gallery.more(); | |
// Bind your events for when the contents of the gallery changes. | |
gallery.on( 'add remove reset', function() { | |
// Something changed, update your stuff. | |
}, gallery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment