Skip to content

Commit

Permalink
Added 'All / Uploaded' filters for new 3.5 media uploader!
Browse files Browse the repository at this point in the history
Signed-off-by: Elliot Condon <e@elliotcondon.com>
  • Loading branch information
elliotcondon committed Jan 20, 2013
1 parent ec29d83 commit 46ca0a1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
21 changes: 17 additions & 4 deletions js/input/file.js
Expand Up @@ -115,12 +115,23 @@
_media.frame = wp.media({
title : _file.text.title_add,
multiple : multiple,
library: {
//type: 'any'
}
});


/*
_media.frame.on('all', function( e ){
console.log( e );
});
*/


// add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
_media.frame.on('title:create', function(){
var state = _media.frame.state();
state.set('filterable', 'uploaded');
});


// When an image is selected, run a callback.
_media.frame.on( 'select', function() {

Expand Down Expand Up @@ -181,7 +192,9 @@

// Finally, open the modal
_media.frame.open();


var state = _media.frame.state();

}
else
{
Expand Down
14 changes: 12 additions & 2 deletions js/input/gallery.js
Expand Up @@ -225,15 +225,25 @@
_media.clear_frame();


// acf.media.frame.content.get().options.filters=true;

// Create the media frame. Leave options blank for defaults
_media.frame = wp.media({
title : _gallery.text.title_add,
multiple : true,
library: {
type: 'image',
library : {
type : 'image',
}
});


// add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
_media.frame.on('title:create', function(){
var state = _media.frame.state();
state.set('filterable', 'uploaded');
});


// When an image is selected, run a callback.
_media.frame.on( 'select', function() {

Expand Down
11 changes: 9 additions & 2 deletions js/input/image.js
Expand Up @@ -113,12 +113,19 @@
_media.frame = wp.media({
title : _image.text.title_add,
multiple : multiple,
library: {
type: 'image'
library : {
type : 'image'
}
});


// add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
_media.frame.on('title:create', function(){
var state = _media.frame.state();
state.set('filterable', 'uploaded');
});


// When an image is selected, run a callback.
_media.frame.on( 'select', function() {

Expand Down

0 comments on commit 46ca0a1

Please sign in to comment.