Dynamically resizing the Gallery Block Container in Squarespace so all images are the same size despite their orientation

So my goal is to have all my images display as the same size, i.e., if a horizontal image is 1300x1000px, then the vertical images in the gallery should be 1000x1300px. As it is now, the gallery-container has a static size based off the widest width image and that images height, it does not seem to incorporate the tallest images height. This results in a gallery where the horizontal images are larger than the vertical images, i.e., 1300x1000px for horizontals and 800x1000px for verticals.

I’ve tried a ton of different CSS approaches and feel that I really am at a place where Javascript is required to achieve this behavior from the gallery-container.

Thanks for helping!