acf_is_image_field()
Returns true when the field only accepts image uploads.
Hooks from the function
Returns
true|false.
Usage
acf_is_image_field( $field );
- $field(array) (required)
- The field array.
Changelog
| Since 6.8.7 | Introduced. |
acf_is_image_field() acf is image field code ACF 6.8.8
function acf_is_image_field( $field ) {
if ( ! is_array( $field ) ) {
/**
* Filters whether the supplied field should be treated as an image field.
*
* @since 6.8.7
*
* @param bool $is_image_field Whether the field only accepts image uploads.
* @param array $field The field array.
*/
return (bool) apply_filters( 'acf/is_image_field', false, $field );
}
$is_image_field = in_array( acf_maybe_get( $field, 'type', '' ), array( 'image', 'gallery' ), true );
/**
* Filters whether the supplied field should be treated as an image field.
*
* @since 6.8.7
*
* @param bool $is_image_field Whether the field only accepts image uploads.
* @param array $field The field array.
*/
$field_type = acf_maybe_get( $field, 'type', '' );
$field_name = acf_maybe_get( $field, '_name', '' );
$field_key = acf_maybe_get( $field, 'key', '' );
$is_image_field = apply_filters( "acf/is_image_field/type={$field_type}", $is_image_field, $field );
$is_image_field = apply_filters( "acf/is_image_field/name={$field_name}", $is_image_field, $field );
$is_image_field = apply_filters( "acf/is_image_field/key={$field_key}", $is_image_field, $field );
$is_image_field = apply_filters( 'acf/is_image_field', $is_image_field, $field );
return $is_image_field;
}