Use Plugin Field inside buildForm() In Drupal 8, I use this code inside my buildForm() method:


$form['medias']['file'] = array(
  '#title' =&gt; t('Image'),
  '#type' =&gt; 'managed_file',
  '#upload_location' =&gt; 'public://image_example_images/',
  '#multiple' =&gt; true,
);



(Bad) Result: http://i.stack.imgur.com/ju0ZU.png

I would like know if it's possible to use a plugin of type "field widget" inside BuildForm() for call and use a field of Image type provided by the core of Drupal:


Thanks.
Possible?

Probably. But it would require a lot of work, as you would basically have to provide all the data and calls that such plugins need. That is very likely more work than re-implementing this functionality yourself.

And creating an entity type would only make sense if you need to manage multiple "things" that each has images attached.