Drupal 8 video_embed_field configuration and APIs

Last updated on
30 April 2025

Creating new provider plugins

The Drupal 8 version uses a plugin system to add new providers. See examples of these here.

Overriding embed codes

If you would like to override specific aspects of an embed code and the provider is an iframe that utilizes the 'video_embed_iframe' render element (as YouTube and Vimeo do), you can do so with the following hooks:

function THEME_preprocess_video_embed_iframe(&$variables) {
  // Change the $variables array!
}

If you would like to override all the videos from a specific provider, this is also possible like so:

function THEME_preprocess_video_embed_iframe__youtube(&$variables) {
  // Change the $variables array for all YouTube videos!
}

The URL and query parameters are all in their own variables, meaning adding or changing the URL or query string is easy. For example to enable autohide on YouTube videos, you can simply write:

function THEME_preprocess_video_embed_iframe__youtube(&$variables) {
  $variables['query']['autohide'] = '1';
}

Help improve this page

Page status: Not set

You can: