Media (< D8.3)

https://www.webwash.net/manage-media-assets-drupal-8/

Media (> D8.3 = Media in Core)

Install core Media module.

Note: Media module will install types:

  • Audio
  • File
  • Image
  • Video
  1. Make sure CTools is installed
  2. Enale Core Media module
  3. Download and enable 'Entity Browser' and make sure it is on 2.x branch
  • drush dl entity_browser-2.x
  1. Download and enable 'Media Entity Browser' and make sure it is on 2.x branch
  • drush dl media_entity_browser-2.x
    • enable Media Entity IEF module

Setup Media Entity Forms

We want to create form modes specifically for Media entities when creating inside a piece of content. Here we will get that ready.

  1. Add new Form Mode for Media
    1. Got to Structure >> Display Modes >> Form Modes >> Add
    2. Click Media
    3. Add "Inline Form"
  2. Create New Form
    1. Goto Structure >> Media Types >> Video >> Manage Form Display
    2. Open Custom Display Settings
    3. Add "Inline Form"
    4. Go to Inline Form tab
    5. Remove un-needed fields

Specific Per Media Type (video for example)

  1. Create Entity Browser (video)
  2. Create Media View for video
    1. Edit /Media Browser/ View
    2. Duplicate Display
    3. Change Filter criteria
      1. Media: Media Type should not be exposed
      2. And Video selected (This display only)
  3. Add Widget (view) with newly created view display
    1. Under the "Configuration" tab click on "Content Authoring".
    2. Click "Entity Browsers"
    3. Add Entity Browser
    4. In "General Information", edit the necessary settings and click "Next".
    5. Edit "Display" settings.
    6. You may skip the next two steps, "Widget Selector" and "Section Display" as you will not have configuration options.
    7. In the "Widgets" section, select the necessary widgets to add and edit the widget settings as needed.
    8. When you're done, click "Finish"!

Setup Media Field on Node

  1. Go to Manage Fields on Node CT
  2. Add field
  3. Reference -> Media
  4. Add title and machine name
  5. Set settings
  6. Goto Manage Form Display
  7. Widget set to Inline Entity Form - Complex
  8. For those settings
    1. Form Mode: Inline Form
    2. Allow users to add new
    3. Allow users to add existing
    4. Autocomplete: Contains
    5. Entity Browser: Video Media Browser
    6. SAVE