How to add an existing custom field to a new content type In my new module I am writing, I am creating a new content type.  In this new content type, I want to attach custom fields for a media player: the media player from MediaFront and a File field with a Media File Selector widget type.

As I understand it, these fields are already defined; I just need to create an instance of each field.  How do I create an instance of each field, and then configure the extra parameters?

I haven't come across any good tutorials on how to do this.
This has been asked before, for a brief example see Clive's answer here. The easiest thing to do is:


create your field and attach it to an entity with the UI logged in at: Admin -> Structure -> Content Types -> Manage Fields
use the code snippet in the below link, supplying your own $entity_type, $field_name and $bundle_name to get the field_create_instance() code outputted directly for you to copy/paste into your modules' hook_install().
...if you get good enough to know the Drupal Field API to build these $settings and $config arrays for fields without this code snippet -- more power to you .... I still use this code snippet myself, it saves time.