限制 wp.media 模态仅显示当前用户上传的文件

restrict wp.media modal to only show files uploaded by current user

我有一个 wordpress 插件,我想在其中创建自定义 wp.media 模态 window 供用户从前端上传文件。我只想显示当前用户上传的文件。我不确定从哪里开始过滤此输入。这是我当前的 javascript wp.media 函数。我可以将库限制为特定文件类型,但我不知道如何按 current_user.

进行过滤
function open_media_window() {
var upload = "";
if (this.window === undefined) {

  if($(this).hasClass('bizimg-select')){
    upload = "bizimg";
  }
  if($(this).hasClass('vcard-file')){
    upload = "vcard";
  }

  if(upload=='bizimg'||upload==""){
    this.window = wp.media({
            title: 'Upload my Bizcard Bizimg',
            library: {type: 'image/*',
          uploadedTo : wp.media.view.settings.post.id},
            multiple: false,
            button: {text: 'Insert'}
        });
  }
  if((upload=='vcard')){
    this.window = wp.media({
            title: 'Upload my Bizcard vCard',
            library: {type: 'text/x-vcard'},
            multiple: false,
            button: {text: 'Insert'}
        });
  }

  var self = this; // Needed to retrieve our variable in the anonymous function below
  this.window.on('select', function() {
          var files = self.window.state().get('selection').toArray();
          var first = files[0].toJSON();
          wp.media.editor.insert('[myshortcode id="' + first.id + '"]');
          //populate selected-bizimg-file with file name
          if(upload=='bizimg'){
            //populate bizimg_post with post id
            $('#bizimg_post').val(first["id"]);
            if($('#selected-bizimg-file')){
              $('#selected-bizimg-file').text(first['filename']);
            }
            if('img.bizimg'){
              $('img.bizimg').attr("srcset", first['url']).attr("src", first['url']);
              $('.bizimg-div').removeClass("border-blue");
            }
          }
          //do the same for vcard
          if(upload=='vcard'){
            $('#vcard_post').val(first["id"]);
            if($('#selected-vcard-file')){
              $('#selected-vcard-file').text(first['filename']);
              $('#vcard-raw-textarea').load(first['url']);
              $('#vcard-upload').css('color','#df9e06');
              $('.remove-file').removeClass('daisy-hidden');
            }
          }

      });

 }
    this.window.open();
   return false;
   }

经过一段时间的挖掘,这很容易。我想将答案归功于 caldas,他在上一个问题中回答了这个问题。 wordpress 仅显示媒体用户在 wp_editor 中上传的内容 。如果您认为这只是一个重复的问题,请举报。我认为这无关紧要,因为我正在处理自定义 wp 媒体模式。