Function
<?php $img_id = get_post_custom_values('img'); foreach ( $img_id as $key => $value ) { echo $value; } ?>
returns me a number - image id. It is necessary to write down 4 similar IDs with a comma in the following code
<?php echo do_shortcode('[gallery ids='']'); ?>