Looks like some of the work I did to automatically crop thumbnails on Ooble is available as a simple CSS property. object-fit The object-fit CSS property sets how the content of a replaced element, such as an img or video, should be resized to fit its container.