Use the_post_thumbnail as background image in LESS CSS [closed]

There’s nothing wrong with an inline style in this case – just set all your other rules in your LESS (like background position, repeat, size), and then in your template:

<div class="something"<?php

if ( $id = get_post_thumbnail_id() ) {
    if ( $src = wp_get_attachment_url( $id ) )
        printf( ' style="background-image: url(%s);"', $src );
}

?>>