I believe you’ll want to set the image as a background image on the div (with inline CSS). In your template’s PHP you can use the following to get the URL to the full-sized featured image (within the Loop, of course):
$image_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
Then to assign this image as the background image, you’d do something like:
<div<?php if( $image_url ) { ?> style="background: url(<?php echo $image_url; ?>) no-repeat center center; background-size: cover;"<?php } ?>>
Related Posts:
- Add custom Attachment Display Setting for images
- Confirmation box when submitting post for review
- disable WP automatically inserted line breaks after an image
- Delete the original big size image after upload and leave only 3 images crunched by media gallery
- How do I detach images from posts?
- upload image in a meta box
- How do I use element instead of tags in WordPress post content having webP support?
- How to remove images from showing in a post with the_content()?
- Getting an alphabetic post list with two letters onclick on letter
- upload featured image from front end using wordpress add media button
- How do I create Comma Separated list of attached image ids?
- POST from jQuery to PHP
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Add confirmation popup on “Move to Trash”
- Remove image from post also removes photo from media library
- The correct way to call posts with ajax
- All my inserted images gets a link to the full image even if it is already full size image
- How do I use Ajax to show the new posts realtime, on the frontpage
- get custom image size
- How to get only text from wordpress post content?
- Get all images out of the posts content
- how to replace embedded “full” sized images within a post with the “large” ones
- Disable Jquery UI post tabs
- Batch process: remove first image from post content
- how can I put an image in a post with original size
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Comma separated all attached image ID numbers except featured image ID number
- Modify Image Source With The_Content Filter?
- Ajax load more button in Recent posts widget
- Ajax Dynamic Archives not showing correct results
- Load post attached images on a single page site with fancybox
- Format the Layout of Images In The Edit Post Textarea?
- Set size for attachments
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- CSS: How can I show a photo beyond the template’s column, but contained within the browser window? [closed]
- Ajaxify This Code
- Show only posts with images and a fixed amount of posts
- How do I locate the exact location where this error is occurring 404 page not found
- How would one change the default url structure of attachments?
- If statement to check if post has image
- Gather posts into a cart/lightbox and share with another user
- What are the benefits of setting a “featured image” for a WP blog post?
- Use Click Image to Play Youtube Video in a WordPress Loop
- update image path with words starting uppercase to lowercase chars
- How to only publish posts with image in it
- Uploading images in custom post form
- Make insterted image point to post url instead of attachment page
- how to give multiple post thumbnails to a post
- Posts page not showing correct image
- How to allow multiple thumbnail upload for Posts?
- get_children returns older images
- How to display post title inside thumbnail?
- Call current post URL in ajax
- How to remove text and retain in caption image using the_content function
- How to get all inline images in post content? [duplicate]
- Adding JS functionality to the Publish button in wp-admin/post.php
- Inserting Media to WordPress Posts
- Author Avatar as default first image
- Link post images to post
- Attachment image single page
- How to change the order of elements within a post?
- Only show featured image on exerpt and exclude images in post
- displaying the categories post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Using the loop to set locations for all posts on a single google map
- how can display a post on home screen without images
- Changing The Default Header POST Title and Description text by category in wordpress
- Site/Post preview is not working on all social media
- How to exclude native lazy loading from first image in post content?
- Rewrite image links from attachment id to attachment link
- Delete media from the post but keep my featured image and post
- Pinterest button shows image options from different posts
- Change the size of the featured image for post?
- How do I fix broken links to images in imported posts’ post_content?
- Thumbnails and images in the blog post are not loading
- Modified core/image rendering not showing in posts – only on pages
- Blog images not showing on homepage
- Many buttons not functioning in WordPress dashboard (as admin)
- How to show category image if no featured image is set?
- Integrate video and iframe in a post type gallery
- How do I use slideToggle inside a wordpress post?
- Printable Page with all Posts from Tag
- how to create other sizes of original image in one go wordpress uploads
- Output wp_link_pages as raw url
- Embed image in post from external url
- Is possible to do this from function.php
- problem with creating a wordpress post slider
- Stop images from being displayed on the front-end of the site
- Relative Image Urls in Posts are starting from root – Not from WordPress Address (URL) at General Settings
- WordPress Media URLs?
- SQL query to remove first image in all posts
- Get post id on click of thumbnail
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- Assign custom class to post content images
- Post thumbnail height problem
- Import alt text in set_post_thumbnail
- Displaying all images from a WordPress post (including media library)
- How to move all images in a post to a single gallery for a bunch of posts?
- website images getting corrupt automatically
- Optimize blog that serves hundred of images and videos