how to contain image size

JavaScript
overflow: 'hidden',
backgroundSize : 'contain',

Source

Also in JavaScript: