Set default value to an image field form element using form_alter I am using this code, but the form doesn't get default image value:
The image is created and exists in the server:

$image = file_get_contents($url);
$destination = 'image.jpg';
$file = file_save_data($image, $destination, FILE_EXISTS_RENAME);


And $form is populated this way:

$form['field_user_picture']['und'][0]['value']['#default_value']['fid'] = $file-&gt;fid;


I think I am missing something, could anybody help?
Try it like this:

$form['field_user_picture']['und'][0]['#default_value']['fid'] = $file-&gt;fid;


(Remove ['value'] key.)