function template_preprocess_media

Same name and namespace in other branches
  1. 10 core/modules/media/media.module \template_preprocess_media()
  2. 11.x core/modules/media/media.module \template_preprocess_media()
  3. 9 core/modules/media/media.module \template_preprocess_media()
  4. 8.9.x core/modules/media/media.module \template_preprocess_media()

Prepares variables for media templates.

Default template: media.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An array of elements to display in view mode.
  • media: The media item.
  • name: The label for the media item.
  • view_mode: View mode; e.g., 'full', 'teaser', etc.

Deprecated

in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme().

See also

https://www.drupal.org/node/3504125

File

core/modules/media/media.module, line 28

Code

function template_preprocess_media(array &$variables) : void {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
  \Drupal::service(MediaThemeHooks::class)->preprocessMedia($variables);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.