uploads - Add media attachment filter to custom wp.media frame

Using wp.media function to create custom uploader popup I can't find argument to show attachment filters. if(typeof

Using wp.media function to create custom uploader popup I can't find argument to show attachment filters.

if(typeof wp === 'undefined' || typeof wp.media === 'undefined') {
  return false;
}

var frame = wp.media({
   title: 'Custom title',
   multiple: false
});

My result:

Desired result:

Any help will be appreciated

Using wp.media function to create custom uploader popup I can't find argument to show attachment filters.

if(typeof wp === 'undefined' || typeof wp.media === 'undefined') {
  return false;
}

var frame = wp.media({
   title: 'Custom title',
   multiple: false
});

My result:

Desired result:

Any help will be appreciated

Share Improve this question asked Jul 20, 2019 at 13:44 Anton LukinAnton Lukin 8875 silver badges17 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4 +50

You need to make use of filterable property. To do that, you can extend the library and use that as a custom state.

// Create state
var myCustomState = wp.media.controller.Library.extend({
    defaults :  _.defaults({
        id: 'my-custom-state',
        title: 'Upload Image',
        allowLocalEdits: true,
        displaySettings: true,
        filterable: 'all', // This is the property you need. Accepts 'all', 'uploaded', or 'unattached'.
        displayUserSettings: true,
        multiple : false,
    }, wp.media.controller.Library.prototype.defaults )
});

//Setup media frame
frame = wp.media({
    button: {
        text: 'Select'
    },
    state: 'my-custom-state', // set the custom state as default state
    states: [
        new myCustomState() // add the state
    ]
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745303857a4621597.html

相关推荐

  • uploads - Add media attachment filter to custom wp.media frame

    Using wp.media function to create custom uploader popup I can't find argument to show attachment filters. if(typeof

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信