Скриптовый Вариант:
<style>
.wrapper__image {
background: #fbfbfb;
margin: 50px;
display: inline-block;
width: 270px;
height: 420px;
overflow: hidden;
border-radius: 5px;
box-shadow: 10px 20px 70px -18px rgba(0, 36, 100, 0.12);
}
.wrapper__image img:not(.longwidth) {
width: 100%;
height:auto;
}
.wrapper__image img.longwidth {
height: 100%;
width: auto;
}
</style>
<script type="text/javascript">
function isLongWidth (that){
if(that.width>that.height)that.className = "longwidth";
}
</script>
<div class="wrapper__image"><img src="https://d13yacurqjgara.cloudfront.net/users/182238/screenshots/2604379/12-fire.jpg" onload="isLongWidth(this)"></div>