JSFiddle - React, Tailwind, and code Playground
HTML
<div class="cover-image" data-image-src="http://lorempixel.com/400/400/">
CSS
.cover-image {
width:300px;
height:300px;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
JavaScript
$( ".cover-image" ).each(function() {
var attr = $(this).attr('data-image-src');
if (typeof attr !== typeof undefined && attr !== false) {
$(this).css('background', 'url('+attr+') center center');
}
});