add_filter(
'sp_wpcp_image_attachments',
function( $attachments, $shortcode_id ) {
// your shortocde id
if ( '1252' === $shortcode_id ) {
$gallery = get_field('gallery');
if ( is_array( $gallery ) ) {
$attachments = $gallery;
}
}
return $attachments;
},
10,
2
);