images keep their original proportions and are both horizontally and vertically centered

It was necessary to nest the images in an extra outer div again to do this (instead of p element before).
a quick fix for traversing the array of loaded images again from the beginning in case there are more images needed than there are images loaded