ft_api_display_image_field
API
This function is included for people with multi-page forms that contain file upload fields - specifically, file upload fields which are used to upload images. What this function does is take care of all the code needed for displaying the image in your form - either on the original form page, if the user returns to the page to edit some values - or on some sort of "review" page where they can see all the values they inputted up to that point.
Usage is extremely simple. Imagine the file field upload section of your form looks something like this:
File: <input type="file" name="regular_file" />
Now add the following PHP:
File: <input type="file" name="regular_file" />
<?php
$params = array(
"field_name" => "regular_file"
);
ft_api_display_image_field($params);
?>
Note that the single required parameter passed to ft_api_display_image_field is the name attribute of the file upload field.
What this code now does is display the image in the webpage - if it's already been uploaded. Also, it displays a "Delete File" button, where the user can choose to delete the uploaded file. Note that the original file upload field is still in the HTML. If the user uploads another image, the system automatically deletes the old file and uploads the new image.
The following optional parameters can also be passed to the function, to give you a little more control:
- width - lets you specify the width of the image. This just adds a width="" attribute to the image tag.
- height - - lets you specify the height of the image. This just adds a height="" attribute to the image tag.
- namespace - only required if you specified a custom namespace in the original ft_api_init_form_page function.
- hide_delete_button - lets your omit the delete button.
- delete_button_label - lets you override the default text that appears on the delete button ("Delete file").