Title: get the post thumbnail sizing
Last modified: August 31, 2016

---

# get the post thumbnail sizing

 *  Resolved [double_dd](https://wordpress.org/support/users/double_dd/)
 * (@double_dd)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get-the-post-thumbnail-sizing/)
 * Hi,
 * I’m creating previous and next buttons for each single blog post. So I have returned
   the thumbnails for each previous and next post.
 * The issue is I want to hard crop the thumbnails returned to a specific size due
   to some featured images being portrait vs landscape.
 * 1st version of my code:
 *     ```
       $prevPost = get_previous_post('true');
       $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(300,300, true));
       ```
   
 * The portrait thumbnail image assigned to one of the posts is being resized but
   only on one edge. It’s not turning into a 300×300 square with a hard crop.
 * Can this crop be made here? or does it have to happen when the thumbnail is added
   to the post (via adding a new image size)?

Viewing 1 replies (of 1 total)

 *  Thread Starter [double_dd](https://wordpress.org/support/users/double_dd/)
 * (@double_dd)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get-the-post-thumbnail-sizing/#post-7029010)
 * UPDATE
 * It looks as though you can’t crop on the fly (or at least I couldn’t make this
   work).
 * So my code in my functions.php file is as follows:
 *     ```
       add_theme_support( 'post-thumbnails' )//this adds thumbnail support;
       add_image_size( 'prevnextimage', 400, 300, true );//this adds a new image size
       ```
   
 * In my single.php file the code is as follows:
 *     ```
       <?php $prevPost = get_previous_post('true');
       $prevthumbnail = get_the_post_thumbnail($prevPost->ID, 'prevnextimage'); ?>
       ```
   
 * I had to then use the regenerate thumbnail plugin here: [https://wordpress.org/plugins/regenerate-thumbnails/](https://wordpress.org/plugins/regenerate-thumbnails/)

Viewing 1 replies (of 1 total)

The topic ‘get the post thumbnail sizing’ is closed to new replies.

## Tags

 * [crop](https://wordpress.org/support/topic-tag/crop/)
 * [featured image](https://wordpress.org/support/topic-tag/featured-image/)
 * [Sizing](https://wordpress.org/support/topic-tag/sizing/)
 * [thumbnail](https://wordpress.org/support/topic-tag/thumbnail/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [double_dd](https://wordpress.org/support/users/double_dd/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/get-the-post-thumbnail-sizing/#post-7029010)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
