Responsive Images by Aspect Ratio

HTML

<div class="wrapper">
    <div class="box">
        <div class="image" style="background-image: url('https://placehold.it/350x150');"></div>
    </div>

</div>

CSS

.box {
    position: relative;
    
    /* ↓ used to show effects ↓ */
    width: 500px;
    background-color: #aaa;
    float: left;
    border: 1px solid #000;
    margin: -1px;
    /* ↑ used to show effects ↑ */
}

.box:before {
    display: block;
    content: '';
    
    /* ↓ change this to change ratio ↓ */
    padding-top: 100%;
    /* ↑ change this to change ratio ↑ */
}


.image {
    background-size: contain;
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-position: center;
}