Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Overview

This module actually comes as a helper, to assist developers who wish to create
a custom form with image uploads preview, using the form API.
It is more suitable for the examples project and really after understanding
the code you may snippet to your module the relevant parts.

If you ever wanted to create a image upload field with an image preview on a custom form using the form api, this module may just be the thing you need !
Simple and easy to understand how you can achieve an image preview.

Features

This module gives you a handicap to set a default image preview for your forms if you wish to use the module's theme process.
- More than that, it will guide you through if you wish to make different image preview for diversion of fields.

Requirements

Image module - Drupal 7 Core.
The module itself has no particular PHP, database, or Drupal requirements, other than it only works with Drupal 7.x.

Configuration

(optional)
Just go to the Form API Image Field settings, under config/user-interface.
- Choose the image style you wish to use for previews.

All you need to do to use this module is to add a managed_file field and apply
the #theme attribute value "fapi_image_preview"

Example (Minimal):

  $form['imagefield'] = array(
    '#type' => 'managed_file',
    '#upload_location' => 'public://YOUR_PATH/',
    '#theme' => 'fapi_image_preview'
  );

Project information

  • Created by ohadsh535 on , updated