class-evf-field-address.php
1 year ago
class-evf-field-ai.php
1 year ago
class-evf-field-captcha.php
4 weeks ago
class-evf-field-checkbox.php
2 months ago
class-evf-field-color.php
4 weeks ago
class-evf-field-country.php
2 months ago
class-evf-field-credit-card.php
4 weeks ago
class-evf-field-date-time.php
4 weeks ago
class-evf-field-divider.php
2 years ago
class-evf-field-email.php
1 year ago
class-evf-field-file-upload.php
1 year ago
class-evf-field-first-name.php
1 year ago
class-evf-field-hcaptcha.php
4 months ago
class-evf-field-hidden.php
1 year ago
class-evf-field-html.php
9 months ago
class-evf-field-image-upload.php
1 year ago
class-evf-field-last-name.php
1 year ago
class-evf-field-likert.php
1 year ago
class-evf-field-lookup.php
4 weeks ago
class-evf-field-number.php
1 year ago
class-evf-field-password.php
4 weeks ago
class-evf-field-payment-authorize-net.php
4 weeks ago
class-evf-field-payment-checkbox.php
4 weeks ago
class-evf-field-payment-coupon.php
4 weeks ago
class-evf-field-payment-gateway-selector.php
4 weeks ago
class-evf-field-payment-quantity.php
4 weeks ago
class-evf-field-payment-radio.php
4 weeks ago
class-evf-field-payment-single.php
4 weeks ago
class-evf-field-payment-square.php
1 year ago
class-evf-field-payment-subscription-plan.php
4 weeks ago
class-evf-field-payment-subtotal.php
4 weeks ago
class-evf-field-payment-total.php
4 weeks ago
class-evf-field-phone.php
1 year ago
class-evf-field-privacy-policy.php
2 months ago
class-evf-field-private-note.php
1 year ago
class-evf-field-progress.php
4 weeks ago
class-evf-field-radio.php
2 months ago
class-evf-field-range-slider.php
4 weeks ago
class-evf-field-rating.php
2 months ago
class-evf-field-recaptcha.php
4 months ago
class-evf-field-repeater.php
4 weeks ago
class-evf-field-reset.php
4 weeks ago
class-evf-field-scale-rating.php
1 year ago
class-evf-field-select.php
1 year ago
class-evf-field-signature.php
4 weeks ago
class-evf-field-text.php
1 year ago
class-evf-field-textarea.php
1 year ago
class-evf-field-title.php
2 years ago
class-evf-field-turnstile.php
4 months ago
class-evf-field-url.php
1 year ago
class-evf-field-wysiwyg.php
2 months ago
class-evf-field-yes-no.php
1 year ago
payment-amount-helpers.php
4 weeks ago
class-evf-field-image-upload.php
89 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Image upload field |
| 4 | * |
| 5 | * @package EverestForms\Fields |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * EVF_Field_Image_Upload Class. |
| 13 | */ |
| 14 | class EVF_Field_Image_Upload extends EVF_Form_Fields_Upload { |
| 15 | |
| 16 | public $field_id = ''; |
| 17 | |
| 18 | public $field_data = ''; |
| 19 | |
| 20 | /** |
| 21 | * Constructor. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | $this->name = esc_html__( 'Image Upload', 'everest-forms' ); |
| 25 | $this->type = 'image-upload'; |
| 26 | $this->icon = 'evf-icon evf-icon-img-upload'; |
| 27 | $this->order = 30; |
| 28 | $this->group = 'advanced'; |
| 29 | $this->settings = array( |
| 30 | 'basic-options' => array( |
| 31 | 'field_options' => array( |
| 32 | 'label', |
| 33 | 'description', |
| 34 | 'upload_message', |
| 35 | 'limit_message', |
| 36 | 'extensions', |
| 37 | 'max_size', |
| 38 | 'max_file_number', |
| 39 | 'required', |
| 40 | 'required_field_message_setting', |
| 41 | 'required_field_message', |
| 42 | ), |
| 43 | ), |
| 44 | 'advanced-options' => array( |
| 45 | 'field_options' => array( |
| 46 | 'meta', |
| 47 | 'label_hide', |
| 48 | 'media_library', |
| 49 | 'css', |
| 50 | ), |
| 51 | ), |
| 52 | ); |
| 53 | |
| 54 | parent::__construct(); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Define additional field properties. |
| 59 | * |
| 60 | * @since 1.0.0 |
| 61 | * |
| 62 | * @param array $properties Field properties. |
| 63 | * @param array $field Field settings. |
| 64 | * @param array $form_data Form data and settings. |
| 65 | * |
| 66 | * @return array of additional field properties. |
| 67 | */ |
| 68 | public function field_properties( $properties, $field, $form_data ) { |
| 69 | $this->form_data = (array) $form_data; |
| 70 | $this->form_id = absint( $this->form_data['id'] ); |
| 71 | $this->field_id = $field['id']; |
| 72 | $this->field_data = $this->form_data['form_fields'][ $this->field_id ]; |
| 73 | |
| 74 | // Input Primary: adjust name. |
| 75 | $properties['inputs']['primary']['attr']['name'] = "evf_{$this->form_id}_{$this->field_id}"; |
| 76 | |
| 77 | // Input Primary: accept image file extensions. |
| 78 | $properties['inputs']['primary']['attr']['accept'] = 'image/*'; |
| 79 | |
| 80 | // Input Primary: allowed file extensions. |
| 81 | $properties['inputs']['primary']['data']['rule-extension'] = implode( ',', $this->get_extensions( 'image' ) ); |
| 82 | |
| 83 | // Input Primary: max file size. |
| 84 | $properties['inputs']['primary']['data']['rule-maxsize'] = $this->max_file_size(); |
| 85 | |
| 86 | return $properties; |
| 87 | } |
| 88 | } |
| 89 |