Hi, i think the simplest one line solution.
You have to set in ACF to get ID of image not URL or array. Then:
<?php echo wp_get_attachment_image_src( get_field('field_name'), 'medium' )[0]; ?>
You can use various pictures in multiple lines without need to define each time the $img.
Save your lines and code 🙂