Currently, I am retrieving product images from an API but unfortunately, they do not have consistent dimensions. My goal is to display these images within a 250x250 div.
In some cases, the image is in portrait orientation and should be scaled based on its height without filling the full 250px width. In other cases, when it is landscape, it should scale to the width without filling the full 250px height.
Admittedly, I am unsure of how to achieve this using CSS, if it is possible at all. Any assistance would be greatly appreciated.
Thank you.
edit A commenter pointed out that this question may duplicate another inquiry: Scale image with css to both width and height to scale. While there is some overlap, I did not find the answers provided in that particular question sufficient for my understanding.