Only do the shortcode if the gallery field has a value, otherwise the WP gallery shortcode is doing what is should be doing when no ids are supplied
$image_ids = get_field('gallery', false, false);
if (!empty($image_ids)) {
$shortcode = '[gallery class="fancybox" link="file" columns="4" ids="' .
implode(',', (array)$image_ids) . '"]';
echo do_shortcode( $shortcode );
}