I created a custom form, and I would like add an image field.
I can do that via this code.
$form['main']['image'] = array( '#type' => 'managed_file', '#title' => t('image'), '#default_value' => array(10), );
I can upload and remove the image from my form. However, when I upload an image, I haven't this preview. I mean, when I create a content via the Drupal UI. I can add a pre-configured "image" field. When I upload an image via this "image" field, I have a preview of the image.
And here, when I create the field element programmatically, I haven't a preview of the image when I upload it. What code should I use to get the preview of the image when I upload it via my image field?