# Crop Thumbnails From the Top Instead of the Center

> Makes WordPress crop square thumbnails from the top of each image rather than the middle, so heads in portraits and headlines in screenshots are not cut off.

- Type: PHP
- Runs: Run everywhere
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: thumbnails, cropping, image-sizes
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/media-crop-thumbnails-top/

## Code

```php
// Cropped image sizes that should keep the top of the image.
$wpide_top_crop_sizes = array( 'thumbnail' );

add_action( 'after_setup_theme', function () use ( $wpide_top_crop_sizes ) {
    foreach ( $wpide_top_crop_sizes as $size ) {
        $sizes = wp_get_registered_image_subsizes();
        if ( empty( $sizes[ $size ] ) || empty( $sizes[ $size ]['crop'] ) ) {
            continue;
        }
        add_image_size( $size, $sizes[ $size ]['width'], $sizes[ $size ]['height'], array( 'center', 'top' ) );
    }
}, 100 );
```

## Notes

Applies to new uploads; regenerate thumbnails to update existing images. Also works for other cropped sizes listed in $wpide_top_crop_sizes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Crop Thumbnails From the Top Instead of the Center" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
