How to keep an image's natural aspect ratio when setting height

Setting Custom CSS via JS at the moment. Running it via the ‘run javascript’ action from the Toolbox plugin on page load:

$(function() {
    var div = $('#myElement');
   
    div.css('height', <Plugin_height_value>);
    div.css('width', <Plugin_width_value>);
});

Can’t wait for dynamic height/width becomes a thing on Bubble.