I’m wondering how to include a repeater default value array where each of one makes use of Images as sub-field
Here is an example of how are we trying to implement, but it does not work with images:
add_filter('acf/load_value/key=field_map_section', 'acf_load_section_map_default', 10, 3);
function acf_load_section_map_default($value, $post_id, $field) {
if ($value === false) {
$value = array(
array(
'field_city_country_map' => 'Santiago de Chile, CH',
'field_image_city_country_map' => get_stylesheet_directory_uri() . '/images/icons/ch-sc-icon.png',
'field_point_position_x_map' => '27',
'field_point_position_y_map' => '27',
),
);
}
return $value;
}
Do you have any idea how to achieve this?.
To preset values of the repeater you need to use field keys for the array indexes.
Hey John, thank you for your kindly response, can you please share an example of how to do field keys for the image field?
If you want to set the default value for an image field use an acf/prepare_field filter (use the field key variant) and set $field[‘default_value’] with the attachment ID of the image.