acf_field_image::validate_value
This function will validate a basic file input
Method of the class: acf_field_image{}
No Hooks.
Returns
true|false. The validity status.
Usage
$acf_field_image = new acf_field_image(); $acf_field_image->validate_value( $valid, $value, $field, $input );
- $valid(true|false) (required)
- The current validity status.
- $value(mixed) (required)
- The field value.
- $field(array) (required)
- The field array.
- $input(string) (required)
- The name of the input in the POST object.
Changelog
| Since 5.0.0 | Introduced. |
acf_field_image::validate_value() acf field image::validate value code ACF 6.8.8
public function validate_value( $valid, $value, $field, $input ) {
if ( $valid !== true ) {
return $valid;
}
if ( empty( $value ) ) {
return $valid;
}
if ( is_numeric( $value ) && ! wp_attachment_is_image( $value ) ) {
return __( 'File must be a valid image.', 'acf' );
}
return acf_get_field_type( 'file' )->validate_value( $valid, $value, $field, $input );
}