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:
- removing inline styles from wp-caption div
- Ajax Load More Posts in Category Page
- How to get Images included in Post
- disable WP automatically inserted line breaks after an image
- Find the post an attachment is attached to
- Post slugs and images cannot have same name?
- Download external images if post is publish
- Dynamically update post title in admin page
- Can I load posts via Ajax?
- How to remove images from showing in a post with the_content()?
- How to load post content on index page using ajax when post title in sidebar is clicked
- Unattaching images from a post
- how to display post content without post image?
- How to wrap every image in a post with a div?
- How do I create Comma Separated list of attached image ids?
- how to grab first link in post… and of course call it
- Load post content into div with ajax
- “Uncaught SyntaxError: Unexpected token
- Add an image box besides featured image?
- Remove image from post also removes photo from media library
- Limit function to specific post category
- Remove inline width from figure
- All my inserted images gets a link to the full image even if it is already full size image
- Remove permalink from images when inserting into post
- How to create a load more post entries like Twitter?
- Disable Jquery UI post tabs
- WordPress Theory Lesson – Image Columns within posts with alignment?
- how can I put an image in a post with original size
- jQuery inluclude still seems ncessary for script to work within post
- Get image from post’s gallery
- Image Insert into posts and pages not working after 3.2.1 update
- Copying and pasting emoji in a wordpress post
- Comma separated all attached image ID numbers except featured image ID number
- Modify Image Source With The_Content Filter?
- How to display featured image without it appearing in post?
- Featured Image uploaded, attached and set but only appearing in the media library
- WP_Query with ajax handler returns the same posts
- creating front end image uploader that uploads images as posts
- Errors when uploading images in WP 3.5
- Format the Layout of Images In The Edit Post Textarea?
- Ajax post filters not working
- CSS: How can I show a photo beyond the template’s column, but contained within the browser window? [closed]
- Get all attachment by post excluding featured and content inside
- wp-cli post create & media import issues
- Get attachments for posts that belongs to a specific category
- Issue where WP Featured Image will not display
- Remove Featured Image & All Media Uploaded to the Post
- preg_replace not removed “class”
- Use Click Image to Play Youtube Video in a WordPress Loop
- How to only publish posts with image in it
- Upload attachment from external site
- Disable posts generated from image uploads
- Posts page not showing correct image
- Images showing up in Post Editor, but not in Published Post
- How to retrieve certain number of images from a wordpress post?
- Adding JS functionality to the Publish button in wp-admin/post.php
- Image on rss feed on post
- Change the background of each post according to the category
- Where to insert the other site image url for our wordpress post
- Author Avatar as default first image
- 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
- How to call WordPress First Image Post or else Attached Image or Default
- Regarding Posts
- Changing The Default Header POST Title and Description text by category in wordpress
- Site/Post preview is not working on all social media
- Delete media from the post but keep my featured image and 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 featured images disappeared on my homepage
- Center crop the feature image
- ‘posts’ table should not store the absolute image path
- How to show category image if no featured image is set?
- How to make an image appear as a thumbnail in the blog post?
- Manipulating images inside post content
- Printable Page with all Posts from Tag
- Output wp_link_pages as raw url
- How can I alternate styling of images in a post? [closed]
- Embed image in post from external url
- Is possible to do this from function.php
- problem with creating a wordpress post slider
- Problem with jQuery in post body?
- SQL query to remove first image in all posts
- WP Gallery Image Page Issue When 2 galleries share one image
- Latest news mini images
- Why can’t I see my attachment page information for an image?
- 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
- Extra Theme – Fit image inside of Featured Post Slider
- Is there any SEO impacts on unattached vs attached images for a post in WordPress?
- 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
- Images and menu links disapearing after saving
- Redirection – bulk edit 404s to new tomain
- WordPress portfolio posts: media not displaying if several images