You are here

function template_preprocess_media_audio in Media entity audio 8.3

Template preprocess function for media_audio template.

File

./media_entity_audio.module, line 25
Media entity for audio files.

Code

function template_preprocess_media_audio(&$vars) {
  $guesser = \Drupal::service('file.mime_type.guesser');
  $vars['sources'] = array_map(function ($source) use ($guesser) {
    return [
      'url' => $source,
      'type' => _media_entity_audio_map_mime($guesser
        ->guess($source)),
    ];
  }, $vars['sources']);
  if ($vars['controls']) {
    $vars['attributes']['controls'] = 'controls';
  }
}