Created
May 16, 2016 20:41
-
-
Save beardedtim/354e30b520830d7751401fb632c3cb8d to your computer and use it in GitHub Desktop.
Abstraction for wp.media
This file contains 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
var MediaGallery = { | |
mediaFrame : "", | |
setAttributes : function (title, button, type, multiple) { | |
this.mediaFrame = wp.media({ | |
title: title, | |
button: { | |
text: button | |
}, | |
library: { | |
type: type | |
}, | |
multiple: multiple | |
}); | |
}, | |
open : function() { | |
this.mediaFrame.open(); | |
}, | |
on : function(event, func) { | |
this.mediaFrame.on(event, func); | |
}, | |
selection : function() { | |
return this.mediaFrame.state().get( 'selection' ); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment