jQuery('body').on('click','.thumbnail',function () {
if(wp.media.view.Settings.AttachmentDisplay){
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();
}
});
}
if(wp.media.view.Settings.Gallery){
var GalleryDisplay=wp.media.view.Settings.Gallery;
wp.media.view.Settings.Gallery = GalleryDisplay.extend({
className: "collection-settings gallery-settings",
template: wp.media.template("gallery-settings"),
render: function() {
GalleryDisplay.prototype.render.apply( this, arguments );
this.$el.find('select.link-to').val('none');
this.model.set('link', 'none');
}
});
}
});
此代码我用于使默认附件显示设置为无,并且是我第一次点击任何图像。它没有更新为无。
答案 0 :(得分:0)
(function($, _){
var mediaSettings = wp.media.view.Settings;
var origAttachDisp = mediaSettings.AttachmentDisplay;
mediaSettings.AttachmentDisplay = origAttachDisp.extend({
initialize: function () {
origAttachDisp.prototype.initialize.apply(this, arguments);
this.$el.find('select.link-to').val('none');
this.model.set('link', 'none');
this.updateLinkTo();
}
})
var origGalleryDisp = mediaSettings.Gallery;
mediaSettings.Gallery = origGalleryDisp.extend({
className: "collection-settings gallery-settings",
template: wp.media.template("gallery-settings"),
initialize: function() {
origGalleryDisp.prototype.initialize.apply(this, arguments);
this.$el.find('select.link-to').val('none');
this.model.set('link', 'none');
}
})
}(jQuery, _));