JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<img src="http://upload.wikimedia.org/wikipedia/commons/f/ff/Bonsai_IMG_6404.jpg" class="wp-post-image"/>
</div>
CSS
div{
width: 80px;
height: 80px;
overflow: hidden;
}
.wp-post-image{
}
JavaScript
var vyska = $('img.wp-post-image').height();
var sirka = $('img.wp-post-image').width();
if(sirka > vyska){
$('img.wp-post-image').css('max-height', '100%');
}
else{
$('img.wp-post-image').css('max-width', '100%');
}