您可以通过覆盖相应的主干视图来执行所需操作,主干视图负责呈现附件显示设置窗体。
plugin.php
add_action( \'load-post.php\', \'wpse8170_media_popup_init\' );
add_action( \'load-post-new.php\', \'wpse8170_media_popup_init\' );
function wpse8170_media_popup_init() {
wp_enqueue_script( \'wpse8170-media-manager\', plugins_url( \'/js/media.js\', __FILE__ ), array( \'media-editor\' ) );
}
media.js
(function() {
var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;
wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({
render: function() {
_AttachmentDisplay.prototype.render.apply(this, arguments);
this.$el.find(\'select.link-to\').val(\'none\');
this.model.set(\'link\', \'none\');
this.updateLinkTo();
}
});
})();