I’m sure it could be done with CSS as long as you give your gallery a CSS class name and apply your CSS to that class name through the custom css in the app settings. I don’t do a whole lot with CSS, so I don’t have suggestions off the top of my head, but I would bet it’s possible.
But, have you explored a custom AI component? You could build a comma delimited list of image urls in your table. Then instruct the custom component to display a gallery bound to the column of delimited urls. You could instruct it to use any ratio you choose and possibly have it display a modal or larger version of the image when you click on it.
Somewhat unrelated, but this is a recent post about creating a gallery with the ability to re-sort the images in an array. Similar concept, but you would just need to change the inputs and the AI prompts to fit your needs, such as what to do when clicked and the ratio you want.