To do this, you must create manually the postmeta _wp_attachment_metadata which is a serialized array.
- First you get your thumbnail:
$file = $form->getData();
$thumb = $file['logo'];
- you get your thumbnail characteristics (width, height...):
list($width, $height, $type, $attr) = getimagesize($thumb);
building the array from the thumb charactéristics:
$meta_data_value = array();
$meta_data_value['width'] = $width;
$meta_data_value['height'] = $height;
$meta_data_value['file'] = $slug.'.'.$ext;
$sizes = array();
$sizes['thumbnail'] = array('file' => $slug.'.'.$ext,'width' => 125,'height' => 150,'mime-type' => $mime);
$sizes['medium'] = array('file' => $slug.'.'.$ext,'width' => 250,'height' => 300,'mime-type' => $mime);
$meta_data_value['sizes'] = $sizes;
$meta_data_value['image_meta'] = array('aperture' => 0,'credit' => '','camera' => '','caption' => '','created_timestamp' => 0,'copyright' => '','focal_length' => 0,'iso' => 0,'shutter_speed' => 0,'title' => '');
$meta_data_value = serialize($meta_data_value);
Finally adding the postmeta with Doctrine :
$meta_data = new PostMeta();
$meta_data->setKey('_wp_attachment_metadata');
$meta_data->setValue($meta_data_value);
$meta_data->setPost($logo);// supposing that you create the post $logo
$em->persist($meta_data);
$em->flush();