# Minimum Image Size for an ACF Image Field

> Rejects uploads to a chosen ACF image field when the picture is smaller than the width and height you need, such as for hero banners.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, images, validation
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-image-min-dimensions/

## Code

```php
// Field name and minimum size in pixels.
$wpide_acf_image_field = 'hero_image';
$wpide_acf_min_width   = 1600;
$wpide_acf_min_height  = 600;

add_filter( 'acf/upload_prefilter/name=' . $wpide_acf_image_field, function ( $errors, $file ) use ( $wpide_acf_min_width, $wpide_acf_min_height ) {
    $size = ! empty( $file['tmp_name'] ) ? wp_getimagesize( $file['tmp_name'] ) : false;

    if ( $size && ( $size[0] < $wpide_acf_min_width || $size[1] < $wpide_acf_min_height ) ) {
        $errors['min_dimensions'] = sprintf( 'Images must be at least %1$d × %2$d pixels; this one is %3$d × %4$d.', $wpide_acf_min_width, $wpide_acf_min_height, $size[0], $size[1] );
    }

    return $errors;
}, 10, 2 );
```

## Notes

Applies to new uploads through the field. ACF also has min width and height settings for images picked from the library.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Minimum Image Size for an ACF Image Field" 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/
