I have added the style “background-position: center center;” and it work perfectly!
So the new code will look like this:
<?php
global $post;
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
?>
<div class="mainblogwrapper" style="background-image: url(<?php echo $src[0]; ?> ) !important; background-attachment : fixed;background-position: center center;">
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- What’s the best way to use the Featured Image for responsive web design?
- Adding Featured Image to Post programatically
- How to upload imagick resource to media in wordpress
- How do I get images (with a thumbnail preview) to show in search results?
- Assign a picture URL to a page via PHP
- How to scale image with equal width and height without distortion?
- Echo URL of large version of Featured Image
- Recent posts with featured image or fallback image with permalink
- Set the background to a default image if there isn’t a specified “featured image”
- Three Questions with Twenty Eleven theme
- Resize image to specific dimension (X to Y ratio)
- Get featured image with custom size outside WordPress
- Else/If Statement to Display Photo Descriptions
- How to set a featured image (thumbnail) with PHP?
- Get the featured image url of clicked post
- Generate responsive post thumbnails of same size
- How to Make Thumbnail of Post Stay Animated
- not outputting medium size image URL
- Replace background image with post thumbnail in shortcode
- Resize post thumbnail
- Retrieving specific images from Media Library
- How to display thumbnail if post is assigned one otherwise not
- Setting post thumbnail sizes in template file and functions.php
- add if statement to the featured image
- Remove default Image Sizes
- Generate and upload screenshot as featured image for user-submitted post
- How to register images uploaded via FTP in media library?
- PHP/Manual use of images? – 2 Questions
- Debugging upload problem: What part of WP does actual image-resizing?
- Add custom image sizes to media uploader
- Conditional Statement – check if post has an attachment image
- WordPress loop specific thumbnail size
- Display All Post Attachments and Assign Class to the Last Image?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- How to Display Image Meta underneath EVERY image in EVERY post
- Get most recent media upload
- Convert all images to PNG on file upload
- Escape post image attachments added to template
- Display post image with fancybox
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Trying to add attribute to my posts’ featured image
- Cannot display or echo alt text on featured image
- WP dynamic featured image – Can’t get second featured image url
- Mass update excerpt
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- How to get next image with this code from same post?
- get_children displaying images removed from the page
- Why my image upload button is not working in wordpress widget area?
- Display image from an external rss feed on wordpress without plugins
- WordPress style.css not updating, only after theme reload
- post thumbnail, conditions, else wont work
- WordPress function when file is uploaded, deleted or edited
- height should be set to auto to avoid pixelation in the post thumbnail function
- Download images from media library to computer in BULK?
- Display related posts without a plugin
- How to loop through all the attached images in a post, and get their url one by one
- WordPress function and string as variable?
- Division by zero error in image.php
- Clickable image link sends people to wrong URL
- Only show image from custom field when present
- Upload non-featured image to image field
- I’m unable to call img path using single quotes in an array?
- Display an image based on field value
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- WordPress İmages Upload & Delete Error
- Call featured image url
- Display background color or image with custom meta box?
- Adding a ‘style=’ bit to image_send_to_editor output
- Generate images with html2canvas and the woocommerce api
- I can’t set image ad fatured programatically
- WordPress api post image raw data without being blank in media library
- Retrieve alt text by referencing the img src
- Show next image in array if page is revisited by same logged user
- Bootstrap 4 Carosuel with ACF Repeater field
- How do I stop an Image Address from loading in the Browser?
- How to put 2 php codes in functions.php without site crashing
- How to add WordPress Featured image in tag ..?
- How to add a PHP scripts into WordPress
- How to bind each “the_content” elements to a custom variables
- WordPress generate images size after upload
- Check If bootstrap last column is even or odd (using ACF custom field)
- Add a default style if no Featured image is selected
- How to programmatically set existing image in media library the featured image for a post in wordpress
- Having trouble with customizing blog posts on the home page
- custom post type not showed with bootstrap 4 modal and template part
- Posts in two different columns Bootstrap
- How to include different html tags in the header for different pages?
- get_post_thumbnail_id returns a negative number
- Inline Styling a div from a Custom Metabox
- insert thumbnail image from php script
- How to resize an image server-side before upload?
- Snapshot Theme from WooThemes — empty ‘alt’ attribute
- How to echo a different field if another field is empty?
- HTML in PHP problem [closed]
- An automatic way to crop images of different sizes
- Understanding responsive imagery
- Use URL query string in img src attribute