我创建了一个包含两个输入字段(宽度和高度)的媒体视图模板,我想知道如何在媒体控制器o视图中检索在其中输入的值。
PHP:
function add_my_media_view_template(){
?>
<script type="text/html" id="tmpl-my-media-view">
<label class="setting width">
<span><?php _e(\'Width\'); ?></span>
<input type="text" class="alignment" data-setting="width" />
</label>
<label class="setting height">
<span><?php _e(\'Height\'); ?></span>
<input type="text" class="alignment" data-setting="height" />
</label>
</script>
<?php }
add_action( \'print_media_templates\', \'add_my_media_view_template\');
JS:
wp.media.view.MyMediaViewSettings = wp.media.view.Settings.extend({
className: \'my-media-view\',
template: wp.media.template(\'my-media-view\'),
initialize: function() {
....
}
});
wp.media.controller.Custom = wp.media.controller.State.extend({
initialize: function(){
....
},
// called when the toolbar button is clicked
customAction: function(){
// NEED TO GET THE VALUES OF THE WIDTH AND HEIGHT INPUT FIELDS
}
});
任何帮助都将不胜感激。媒体模式的文档记录很差,很难使用它构建东西。
谢谢