What Are Media Sources in Drupal? for Drupal 8, Drupal 9

Last updated July 13, 2021

Media source plugins provide the link between media entities in Drupal and the actual media asset itself. They are the code that understand the difference between an image, a video, and a Tweet, and perform the translation that allows the media ecosystem to treat all media entities equally. For example, local image files, and remote YouTube videos, can both be catalogued in a similar way as media entities, but they need very different handling when it comes to displaying them.

Media sources are represented as plugins, there are a handful in Drupal core, and a developer can add new plugins to represent any type of media your application needs to catalogue.

In this tutorial we'll learn:

  • How media source plugins relate to Media Types
  • The responsibilities of a media source plugin

By the end of this tutorial you should be able to define the role of a media source plugin and understand what's required to define your own.