the Customizer - proper way to instantiate an image upload control via javascript
I am trying to create an image control using:
wp.customize.control.add(
new wp.customize.Control(
myControlSettingID
{
type: image,
button_labels: {select: 'Select image', change: 'Change image', remove: 'Remove', default: 'Default', placeholder: 'No image selected'...}
description: Upload or select an image for this featured link
id: issue_section_term_apple_settings_link_image
label: Custom image
priority: 1
section: issue_section_term_apple_section
}
)
);
I am using the type property and set it to image which is what the WP_Customize_Image_Control php class has set for the class type property.
This is only spitting out the label and description, and an empty attachment media view div and doesnt produce an active media UI:
div class=attachment-media-view
div class=actions
/div
/div
Do I need to instantiate the control another way, or trigger a JS function to activate the controls?
Also - somewhat related. Because I am creating the control via javascript that means that wont work right? I am trying to toggle this control based on the value of another control. Will I need to manually bind the controls together?
Topic theme-customizer Wordpress javascript
Category Web