I've created a media view template with two input fields (width and height) and I was wondering how to retrieve the values entered in them in a media controller o view.
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
}
});
Any help would be appreciated. The media modal is poorly documented and it's difficult to build things using it.
Thanks