name = __( 'Image Upload', 'weforms' );
$this->input_type = 'image_upload';
$this->icon = 'file-image-o';
}
/**
* Render the text field
*
* @param array $field_settings
* @param integer $form_id
*
* @return void
*/
public function render( $field_settings, $form_id ) {
$unique_id = sprintf( '%s-%d', $field_settings['name'], $form_id );
?>
print_list_attributes( $field_settings ); ?>>
print_label( $field_settings, $form_id ); ?>
help_text( $field_settings ); ?>
get_default_option_settings(true, array('dynamic', 'width') ); // exclude dynamic
$settings = array(
array(
'name' => 'max_size',
'title' => __( 'Max. file size', 'weforms' ),
'type' => 'text',
'section' => 'advanced',
'priority' => 20,
'help_text' => __( 'Enter maximum upload size limit in KB', 'weforms' ),
),
array(
'name' => 'count',
'title' => __( 'Max. files', 'weforms' ),
'type' => 'text',
'section' => 'advanced',
'priority' => 21,
'help_text' => __( 'Number of images can be uploaded', 'weforms' ),
),
);
return array_merge( $default_options, $settings );
}
/**
* Get the field props
*
* @return array
*/
public function get_field_props() {
$defaults = $this->default_attributes();
$props = array(
'max_size' => '1024',
'count' => '1',
);
return array_merge( $defaults, $props );
}
/**
* Prepare entry
*
* @param $field
*
* @return @return mixed
*/
public function prepare_entry( $field ) {
return isset( $_POST['wpuf_files'][$field['name']] ) ? $_POST['wpuf_files'][$field['name']] : array();
}
}