diff --git a/js/input/file.js b/js/input/file.js index 9a2d7016..f441f240 100644 --- a/js/input/file.js +++ b/js/input/file.js @@ -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() { @@ -181,7 +192,9 @@ // Finally, open the modal _media.frame.open(); - + + var state = _media.frame.state(); + } else { diff --git a/js/input/gallery.js b/js/input/gallery.js index f9d634ec..e5914fb6 100644 --- a/js/input/gallery.js +++ b/js/input/gallery.js @@ -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() { diff --git a/js/input/image.js b/js/input/image.js index 5dcd3e7b..baab3b9f 100644 --- a/js/input/image.js +++ b/js/input/image.js @@ -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() {