I basically have a group of images of unknown sizes. Some may have a width > height and vice versa.
I need to display these items scaled to fit in a 300x300 box. Some of these images are smaller than 300x300 and need scaled up and some are larger and need scaled down.
So basically if I have an image that is 100x200, I need it to display at 150x300 and if I have an image that is 800x400 it needs to display as 300x150.
ie one of the dimension need to be fit on the box and other dimension need to be resize as aspect ratio.
Since this is a user selected object in a database, I initially tried this in javascript but I'm struggling. I'm curious if there's a purely CSS way to do this.