Welcome! To use this support forum, please Login or Join Today!

   

Featured image is small and indented to the left

{name}
Rank

Total Posts: 9

Joined 2014-01-30

PM

 

I was wonnedring how to have my featured image centred and full width of the body?

At the moment it’s about half the size it should be, even though the width is over 1000, and it’s not centred? (see image)

Many thanks


Attachments:

https://www.filepicker.io/api/file/j2jHRPtsQBiBbxrki99K

{name}
RankRankRankRank

Total Posts: 3667

Joined 2011-04-27

PM

 

Hi, The featured image doesn’t automatically display images at 100% full width. You wouldn’t want a 1000px image there anyway.

If you want featured images to be the full width at the top of your post content you’ll want to add a few simple overrides. Fortunately, Synapse has hooks to do this for you.

Assuming you’re using a child theme, just add this to your child theme’s functions.php:

This function adds a custom image size (640px x 200px) for all newly uploaded images.

// Add a 640 x 200 image size
function st_custom_size() {
 add_image_size( $name = 'full_post_width', $width = 640, $height = 200, $crop = true );
}
add_action( 'after_setup_theme', 'st_custom_size' );

Adding the function below will insert the image above your posts with the above defined image size.

// Add image before single posts
function st_addSingleImage() {
 global $post;
 $image = get_the_post_thumbnail($id, 'full_post_width', array('class' => 'aligncenter scale-with-grid'));

 if (is_single()) {
 echo $image;
 }
}
add_action('st_before_content','st_addSingleImage',1);

The above override only applies to newly uploaded images, so you’ll want to regenerate your previously uploaded WP images to use this new crop. The Regenerate Images plugin is made just for this purpose. Once you’ve added the functions above and install this plugin, just go to Tools → Regenerate Thumbnails and you should be all set.