How to convert feature image as background image

I am trying create background image out of feature image so I can use the background-size:cover. Here is the code I have but how can I add feature image into . How can I achieve background image technique.

<?php
if ( $post->post_parent )
$post_id = $post->post_parent;
else
$post_id = $post->ID;

if ( $thumbnail = get_the_post_thumbnail( $post_id, ‘post-thumbnail’ ) ) {
echo $thumbnail;
}
?>

Read more here:: How to convert feature image as background image

Leave a Reply

Your email address will not be published. Required fields are marked *