cf_custom_fields_upload_handler

Handle featured image uploads.

Description

cf_custom_fields_upload_handler( (array) $upload, (array) $file, (array) $upload_args ); 

Parameters (3)

0. $upload (array)
The upload.
1. $file (array)
The file.
2. $upload_args (array)
The upload args.

Usage

  1. if ( !function_exists( 'cf_custom_fields_upload_handler' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-custom-fields/includes/to-post-type.php'; 
  3.  
  4. // The upload. 
  5. $upload = array(); 
  6.  
  7. // The file. 
  8. $file = array(); 
  9.  
  10. // The upload args. 
  11. $upload_args = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = cf_custom_fields_upload_handler($upload, $file, $upload_args); 
  15.  

Defined (1)

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

/includes/to-post-type.php  
  1. function cf_custom_fields_upload_handler( $upload, $file, $upload_args ) { 
  2. $upload = wp_handle_upload($upload, array( 'test_form' => false ) ); 
  3. $attachment_id = Caldera_Forms_Files::add_to_media_library( $upload ); 
  4. if ( is_numeric( $attachment_id ) ) { 
  5. Caldera_Forms_Transient::set_transient( 'cf_cf_featured_' . $file ['form_id'], $attachment_id );