<field_id>

Filter for determining if a field value has a valid image file-type extension.

Description

apply_filters( '<field_id>', (bool) $is_valid, (string) $file, (string) $file_ext ); 

The dynamic portion(s) of the hook name refer to the field id attribute.

Parameters (3)

0. $is_valid (bool)
Whether field value has a valid image file-type extension.
1. $file (string)
The file.
2. $file_ext (string)
File extension.

Usage

To run the hook, copy the example below.
  1. $is_valid = apply_filters( '{$field_id}', $is_valid, $file, $file_ext ); 
  2.  
  3. if ( !empty( $is_valid ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the <field_id> callback 
  2. function filter_field_id( $is_valid, $file, $file_ext ) { 
  3. // make filter magic happen here... 
  4. return $is_valid
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "{$field_id}", 'filter_field_id', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "{$field_id}", 'filter_field_id', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/types/CMB2_Type_File_Base.php  
  1. return (bool) apply_filters( "cmb2_{$this->field->id()}_is_valid_img_ext", $is_valid, $file, $file_ext );