~
I guess, a discussion-wise starting point might be:
img.userimg { max-width: 100%; height: auto; }
(As in, I think that that would fix the specific problem you're talking about, but, not without producing some other consequences, too.)
"object-fit: contain" could help some of the consequences, but it also adds space to the top/bottom, so also a bit messy.