Need help with dynamic image grid
To add a row at every 4th item, you can use twig's batch filter:

Twig Batch

Alternatively(a little more hacky) you can do {% if loop.index is divisible by(4) %} stuff {% endif %}. But batch is probably better.