Home › Forums › General Issues › Cannot read 'query' of undefined when adding images
Hi,
Im trying to register some acf fields inside a flexible content box programatically.
one of the flexible content items is a repeater field, intended to have image fields repeat inside of it. I’ve managed to pull the fields to the wordpress admin pages fine, however when clicking the ‘add image’ button on any of the image fields, no media picker window pops up and im left with an error in the console that reads
Uncaught TypeError: Cannot read property 'query' of undefined
at i.addFrameStates (acf-input.min.js?ver=5.7.7:3)
at initialize (acf-input.min.js?ver=5.7.7:3)
at i.t (acf-input.min.js?ver=5.7.7:1)
at i.acf.Model (acf-input.min.js?ver=5.7.7:1)
at i [as constructor] (acf-input.min.js?ver=5.7.7:1)
at new i (acf-input.min.js?ver=5.7.7:1)
at Object.acf.newMediaPopup (acf-input.min.js?ver=5.7.7:3)
at i.selectAttachment (acf-input.min.js?ver=5.7.7:2)
at i.onClickAdd (acf-input.min.js?ver=5.7.7:2)
at i.<anonymous> (acf-input.min.js?ver=5.7.7:1)
The code for the fields follows:
acf_add_local_field_group(array (
'key' => 'site_content',
'title' => 'Custom Content',
//Flexible content field
'fields' => array (
array (
'key' => 'flexi_fields',
'label' => 'Flexible Fields',
'name' => 'acf_flexi_fields',
'type' => 'flexible_content',
'display' => 'block',
'button_label' => 'Add Section',
'menu_order' => 0,
//Add flexi items to array
'layouts' => array (
//Flexi item 1
array (
'key' => 'flexi_field_accordion',
'name' => 'flexi_field_accordion',
'label' => 'Accordion',
),
//Flexi item 2
array (
'key' => 'flexi_field_slider',
'name' => 'flexi_field_slider',
'label' => 'Slider',
)
),
),
),
//location of fields
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post'
),
),
),
));
}
//Field setup for slider
acf_add_local_field(array(
//link to parent
'parent' => 'flexi_fields',
'parent_layout' => 'flexi_field_slider',
//field settings
'key' => 'slider_wrapper',
'name' => 'slider_wrapper',
'label' => 'Slider',
'type' => 'repeater',
'display' => 'row',
'min' => '',
'max' => '',
));
//Image
acf_add_local_field(array(
//link to parent
'parent' => 'slider_wrapper',
//field settings
'key' => 'slider_img',
'name' => 'slider_img',
'label' => 'Image',
'instructions' => '',
'type' => 'image',
'return_format' => 'url',
));
Thanks for any help in advance, this one really has me stumped
The topic ‘Cannot read 'query' of undefined when adding images’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.