Media in Drupal 8+

EVERYTHING YOU NEED TO KNOW

https://slides.com/phenaproxima/d8media

phenaproxima

  • Engineer @ Acquia
     
  • Media coordinator and co-maintainer
     
  • Likes dogs
     
  • Talks too fast

OVERVIEW

  • Architectural wade-in
  • Media fields vs. image fields
  • Live demo! 😱
  • A few useful modules
  • What's next for Media

THE MEDIA SYSTEM

Two modules:

  1. Media represents media as Drupal entities
  2. Media Library makes media reusable in the UI

Media is the plumbing; Media Library is the UI.

MEDIA ARE ENTITIES

  • They have all the superpowers.
    • fieldable
    • revisionable
    • translatable
    • themeable
    • ...etc.​
  • Media items have types
  • similar to content types
     
  • have a source (kind of media)
     
  • have a "source field" to store the most important data

MEDIA TYPES...

All media have a type, and value in their source field.

  • Media is more than files and images
     
  • Consistent across types
     
  • All the benefits of entities
     
  • Reusable!

WHY THIS IS GOOD

...but yes, it is a little more complicated.

IMAGE FIELD

node

image field

node

image field

media

MEDIA FIELD

MEDIA LIBRARY

  • Finally.
  • Author-facing UI for selecting and adding media
  • Simple, usable, accessible
  • Nearly zero configuration
  • Customizable via Views
  • Integrates with CKEditor
  • Can be integrated with other things too

BUT...it only works with media. 😇

LET US RECAP

  • Media:
    • are entities
    • have a type
    • keep crucial data in a field
    • sources can be more than just images
  • With image fields, content owns image. With media fields, media owns image and is referenced by content
  • Media Library is 😍 but only works with media

LIVE DEMO!

A FEW USEFUL MODULES

(and an almost-useless one)

👍 USEFUL MODULE:

ENTITY BROWSER

  • Generic and powerful
     
  • Takes work to set up
     
  • Works alongside Media Library
     
  • Best for unusual use cases
     
  • 👉 Media Library is not a replacement!
  • Generic and powerful
     
  • Takes work to set up
     
  • Works alongside core tools
     
  • Best for unusual use cases

👍 USEFUL MODULE:

ENTITY EMBED

  • Helps track where entities are used
     
  • Tracks various usage methods
     
  • Useful for managing reusable media
     
  • Extensible via custom code

👍 USEFUL MODULE:

ENTITY USAGE

  • Media Entity Twitter
     
  • Media Entity Instagram
     
  • Media Entity Audio
     
  • Media Entity SoundCloud
     
  • ...and more!

drupal.org/project/media_entity

👍 USEFUL MODULES:

MEDIA ENTITY X

  • Obsolete!
     
  • Became the core Media module
     
  • Most of its ecosystem now uses core tools
     
  • 8.x-2.0 is a migration to core

🙏 Please don't use this module.

👎 (ALMOST) USELESS MODULE:

MEDIA ENTITY

WHAT'S NEXT?

  • Fix allll the bugs (especially UX and a11y)
     
  • Get more sites on Media instead of File/Image
     
  • Media out of the box with Drupal

GO FORTH AND BUILD GREAT THINGS!

@phenaproxima

slides: tinyurl.com/ybtmfgs7

Media in Drupal 8: Everything you need to know

By Adam G-H

Media in Drupal 8: Everything you need to know

  • 952