Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm trying to add an AJAX callback on a file-upload form-item. By doing so, I'm trying to upload a file automatically and immediately show a preview of this image.
The automatic file upload can be done with the AutoUpload-module, but this doesn't generate a preview of the image, hence the custom AJAX callback.

I tried to add an AJAX callback on my form with help of the form API, like this:

$form['field_frontpage_images']['#ajax'] = array(
          'callback'=>'create_preview',
          'wrapper'=> 'image_preview',
          'method'=> 'replace',
          'effect'=> 'fade',
);

Where the create_preview-callback provides an image preview. But I don't get things working... Is there a method/module I'm overlooking here?

How can I get a preview on uploading an image when creating content (preferable by not having to use the 'upload' button)?

share|improve this question
If you look in the console window of Firebug or similar, what is being returned in the response to the AJAX request? – littledynamo Mar 5 at 12:59

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.