I have an issue with a site I'm building which contains a gallery page. The layout they require is to have a variable amount of images per row (maximum 4 or less), and for all these images to fit the entire width of the container element (for this case I'll go with 1100px), but all have the same height and aspect ratio, and to not crop the images.
Here is an example of what I mean (where the coloured blocks represent the images): https://i.stack.imgur.com/oHHMj.jpg
I'd appreciate any help with creating a php function which could take the dimensions of 4 given images, and calculate the width and height values for each image to enable them to fit snuggly into the container, which I can apply with some inline css.
I can manage getting the image dimensions and applying the inline css, but I'm stumped on the calculations I'd need to perform to actually work out what their respective sizes should be.
Many thanks!