我也遇到了同样的问题,最终解决了。基于您拥有的线程followed, 现在必须扩展WP-core/WP-includes/js/media视图的“更新”功能。js。
转到“jQuery(document).ready(function()…”“print\\u media\\u templates”操作的一部分,然后尝试以下操作:
<script>
jQuery(document).ready(function()
{
wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
// add your custom options template (you probably already did this)
template: function(view){
return wp.media.template(\'gallery-settings\')(view)
+ wp.media.template(\'custom-gallery-setting\')(view);
},
// now extend the update function
update: function( key ) {
// call originial function: you want to *extend* it,
// not to override it completely!
wp.media.view.Settings.prototype.update.call( this, key );
// get the current value of your gallery_image_title_text_size attribute
var currentTextSize = this.model.attributes.gallery_image_title_text_size;
// get the data-setting elements, in your case \'gallery_image_title_text_size\':
$setting = this.$( \'[data-setting="gallery_image_title_text_size"]\' );
// for each of this setting (if it\'s a radio button),
// check the value stored by your attributes
// and set the radio button accordingly
$setting.each( function ( index ) {
if ( $( this ).is( \'input[type="radio"]\' ) &&
currentTextSize == $( this ).val() ) {
$( this ).attr( \'checked\', true );
} else {
$( this ).attr( \'checked\', false );
}
} );
}
} );
} );
</script>