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
- Add custom Attachment Display Setting for images
- Confirmation box when submitting post for review
- 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
- Delete the original big size image after upload and leave only 3 images crunched by media gallery
- Post slugs and images cannot have same name?
- Add existing images from Media Library in to custom gallery
- Replace image attributes for lazyload plugin (data-src)
- How do I detach images from posts?
- Download external images if post is publish
- Dynamically update post title in admin page
- How do I sort (order) the results from `get_children()`?
- upload image in a meta box
- Can I load posts via Ajax?
- 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
- 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?
- upload featured image from front end using wordpress add media button
- How do I create Comma Separated list of attached image ids?
- Get post embedded image caption
- how to grab first link in post… and of course call it
- Load post content into div with ajax
- POST from jQuery to PHP
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- “Uncaught SyntaxError: Unexpected token
- Add confirmation popup on “Move to Trash”
- Add an image box besides featured image?
- Remove image from post also removes photo from media library
- Limit function to specific post category
- Post taxonomy from exif data
- Remove inline width from figure
- 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
- Remove permalink from images when inserting into post
- 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
- How to create a load more post entries like Twitter?
- Disable Jquery UI post tabs
- WordPress Theory Lesson – Image Columns within posts with alignment?
- Batch process: remove first image from post content
- how can I put an image in a post with original size
- jQuery inluclude still seems ncessary for script to work within post
- Show featured image next to post-teasers in Genesis Framework?
- Get image from post’s gallery
- Image Insert into posts and pages not working after 3.2.1 update
- How to retrieve the postID in a “image_send_to_editor” hook function?
- 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?
- Can I use images as anchor tags with
- Ajax load more button in Recent posts widget
- Ajax Dynamic Archives not showing correct results
- Featured Image uploaded, attached and set but only appearing in the media library
- Load post attached images on a single page site with fancybox
- 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?
- Set size for attachments
- Get post id on click of thumbnail
- Post thumbnail dependant on category
- 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
- How do I insert a custom field in a user submitted post?
- Only show posts with image and the correct ammount of posts in loop
- jquery: getting contents of #content field on post page
- Assign custom class to post content images
- Extra Theme – Fit image inside of Featured Post Slider
- Post thumbnail height problem
- Get attachment if matches a variable
- Is there any SEO impacts on unattached vs attached images for a post in WordPress?
- Import alt text in set_post_thumbnail
- Broken images after importing posts and opening in Gutenberg
- Search doesn’t display posts with images
- 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?
- Inside post image title has been posting as a post title on my main post page
- Download button under all images WordPress
- website images getting corrupt automatically
- Optimize blog that serves hundred of images and videos
- Images and menu links disapearing after saving
- Images being uploaded via WP Media are not attached even they are used by some CPT posts
- Redirection – bulk edit 404s to new tomain
- how to display the actual size of the picture in post
- WordPress portfolio posts: media not displaying if several images
- Set Featured Image of a post
- Is there a way to eliminate flyout menus when adding a post?
- How to delete Full Size options from post Add Media?