object-fit test
HTML
<div id="container">
<img id="foo" src="http://dummyimage.com/100x200/000/fff.jpg"/>
</div>
<pre id="result">
</pre>
CSS
#container {
width: 400px;
height: 300px;
border: 1px solid blue;
}
#foo {
width: 100%;
height: 100%;
object-fit: contain;
object-position: 25% 0;
}
JavaScript
var result = '';
var $image = $( 'foo' );
/* TODO: Insert code here to calculate the real shown size of $image */
/*
The task is done, when `result` contains the dynamically calculated
string:
width: 150px
height: 300px
left: 62.5px
right: 212.5px
*/
$('#result').text( result );