Add a Media Field to a Content Type in Drupal

The most common way to use Drupal’s Media items is to add fields to content types, allowing the Media entities to be associated with one or more pieces of content. For example, adding a cover image to an article, or embedding a set of YouTube videos into a tutorial. This is accomplished by adding a Media field to the content type in question.

In this tutorial we’ll:

  • Explain what different field-specific configuration options do
  • Add a Media field to the existing¬†Article¬†content type
  • Explain what the different field-specific configuration options do
  • Confirm that it worked by verifying that the form for adding an article has the new field

By the end of this tutorial you’ll know how to add a Media field to any content type, or any other fieldable entity, in order to allow Media items to be associated with the content.

Find, Add, Edit, and Delete Media Entities in Drupal

Media entities in Drupal are content entities, and can be administered like most other Drupal content entities. In most cases you’ll likely add new Media entities via the Media Library widget when creating a new content entity like an Article. However, it’s possible to add them to the library without having to attach them to a piece of content. You may also want to update an existing Media entity, or just search the library to see whether something already exists.

In this tutorial we’ll:

  • Learn what a Media entity is in Drupal
  • Get an overview of the main Media management page
  • Learn how to add, edit, and delete, Media entities
  • Learn how to bulk edit Media entities in Drupal

By the end of this tutorial you’ll know how to perform basic find, add, edit, and delete operations to manage the Media entities in your library.

Use Drupal Media Library to Browse Media Entities

The Drupal core Media Library module provides an enhanced user interface for locating Media entities and attaching them to an article. It’s a drop-in replacement for the default entity reference widget which uses a not very intuitive autocomplete field. Using the Drupal core Media Library module requires minimal configuration.

If you want to provide content creators with a gallery-like library of Media entities that they can browse through in order to find the ones they want to add to their content, the Media Library is the easiest way to do it. It can be configured to work with both Media fields and the CKEditor powered WYSIWYG editor commonly used for editing the body field of Drupal nodes. There’s really no reason not to use it.

In addition to providing a better UI for locating existing Media entities, the Media Library provides a way to create new Media entities right from the content creation form. This prevents an otherwise confusing requirement where Media entities need to be created, via a different set of forms, before they can be used.

In this tutorial we’ll:

  • Install and configure the Media Library module to work with Media fields
  • Use the user interface provided by the Media Library to improve the experience of finding and selecting Media entities to associate with a piece of content

By the end of this tutorial you’ll know how to replace the default entity reference widget used for selecting Media entities with the much improved Media Library UI.

Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff
Read Bluff