Hi @milanomia
I was unaware that you wanted to use a shortcode with the WP gallery. You will need to write something like this:
<?php
$images = get_field('gallery');
$image_ids = array();
$max = 4;
$i = 0;
if( $images )
{
foreach( $images as $image )
{
$i++;
if( $i > $max){ break; }
$image_ids[] = $image['id'];
}
}
$shortcode = '[gallery columns="1" link="file" size="medium" ids="' . implode(',', $image_ids) . '"]';
echo do_shortcode( $shortcode );
?>