One way to enhance the appearance of a parent div is by extracting the image source and setting it as the background image, before removing the original image. Here's a simple example of how this can be accomplished:
Sample CSS :
.backstretch {
width: 50%;
height: 200px;
margin: 200px auto;
}
HTML
<div class="big-leader">
<div class="backstretch">
<img src="test.png">
</div>
<div class="backstretch">
<img src="test1.jpg">
</div>
</div>
JQUERY :
$(function() {
$('.backstretch').each(function(index, el) {
var img = $(el).children('img');
$(el).css('background', 'url(' + img.attr('src') + ') 50% 50% / cover fixed');
img.remove();
});
});
$(function() {
$('.backstretch').each(function(index, el) {
var img = $(el).children('img');
$(el).css('background', 'url(' + img.attr('src') + ') 50% 50% / cover fixed');
img.remove();
});
});
.backstretch {
width: 50%;
height: 200px;
margin: 200px auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="big-leader">
<div class="backstretch">
<img src="http://via.placeholder.com/350x150">
</div>
<div class="backstretch">
<img src="http://via.placeholder.com/500x200">
</div>
</div>