How to display a thumbnail through the background?

Standard Wordpress displays the thumbnail in the img, how to alter the background ?
You should get something like this...
July 9th 19 at 12:56
1 answer
July 9th 19 at 12:58
Found the answer

<?php global $post; ?>
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post--->id), array( 5600,1000 ), false, " );

<div style="background: url(<?php echo $src[0]; ?> ) !important;">a text </div>

Find more questions by tags WordPress