Last active
April 3, 2017 07:58
-
-
Save bitfade/4460948 to your computer and use it in GitHub Desktop.
Revisions
-
bitfade revised this gist
Jan 5, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function select() { } function reset() { // called when dialog is closed by "close" button / "ESC" key // use the following line unbind the event // workflow.off("select"); } -
bitfade revised this gist
Jan 5, 2013 . No changes.There are no files selected for viewing
-
bitfade created this gist
Jan 5, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ var workflow = wp.media({ title: 'Select the images', // use multiple: false to disable multiple selection multiple: 'add', button: { text: 'Add selected images' }, library: { type: 'image' } }); function getAttachment(attachment) { attachment = attachment.toJSON(); return {id:attachment.id,url:attachment.url}; } function select() { // use this to unbind the event // workflow.off("select"); // get all selected images (id/url attributes only) console.log(workflow.state().get('selection').map(getAttachment)); } function reset() { // called when user media uploaded is closed via "close" button / "ESC" key // use the following line unbind the event // workflow.off("select"); } // bind event handlers workflow.on("select",select); workflow.on("escape",reset); // open the dialog workflow.open();