<?php while (have_posts()) : the_post(); /* grab the url for the full size featured image */ $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); /* Background Image as a div bg. */ echo '<div class="featuredImage" style="background-mage:url('.esc_url($featured_img_url).');"></div>'; ?> <?php endwhile; ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter