无法提供工作示例,但中有此相关部分wp-includes/js/media-views.js on Line 3173:
media.view.AttachmentFilters.Uploaded = media.view.AttachmentFilters.extend({
createFilters: function() {
var type = this.model.get(\'type\'),
types = media.view.settings.mimeTypes,
text;
if ( types && type )
text = types[ type ];
this.filters = {
all: {
text: text || l10n.allMediaItems,
props: {
uploadedTo: null,
orderby: \'date\',
order: \'DESC\'
},
priority: 10
},
uploaded: {
text: l10n.uploadedToThisPost,
props: {
uploadedTo: media.view.settings.post.id,
orderby: \'menuOrder\',
order: \'ASC\'
},
priority: 20
}
};
}
});
一个筛选器引用
uploadedTo: null
另一个是
uploadedTo: media.view.settings.post.id
. 因此,这相当于“所有附件”和“附加到当前帖子”。
当附件未连接时,其uploadedTo
值为0。我只是尝试为它创建一个新的过滤器,但它根本没有返回任何附件(我的数据库中有未连接的上传)。
Line 581 of wp-includes/js/media-models.js 显示如何构造筛选机制:
uploadedTo: function( attachment ) {
var uploadedTo = this.props.get(\'uploadedTo\');
if ( _.isUndefined( uploadedTo ) )
return true;
return uploadedTo === attachment.get(\'uploadedTo\');
}
我猜零值会通过。isUndefined(),但它没有。所以我在这里几乎一无所知。但也许这会把你或其他人推向这个方向。媒体框架大部分仍然没有记录。