ACF validate image size with ACF5
-
Hello,
First of all, thanks a lot for this greate plug !!!!Do you have a tips for me, i try to use ” validate_value “with this code but not working
with ACF image field is ok but not with ACF image crop ?
/*————————–*
/* ACF validate image size for field
/*————————–*/add_filter(‘acf/validate_value/name=poster_of_event’, ‘my_acf_validate_value’, 10, 4);
function my_acf_validate_value( $valid, $value, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {return $valid;
}
// load image data
$data = wp_get_attachment_image_src( $value, ‘full’ );
$width = $data[1];
$height = $data[2];if( $data < 300) {
$valid = ‘Image must be at least W :300px & H :300px’;
}
// return
return $valid;}
- The topic ‘ACF validate image size with ACF5’ is closed to new replies.