function media_library_preprocess_media in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media_library/media_library.module \media_library_preprocess_media()
- 10 core/modules/media_library/media_library.module \media_library_preprocess_media()
Implements hook_preprocess_media().
File
- core/
modules/ media_library/ media_library.module, line 230 - Contains hook implementations for the media_library module.
Code
function media_library_preprocess_media(&$variables) {
if ($variables['view_mode'] === 'media_library') {
/** @var \Drupal\media\MediaInterface $media */
$media = $variables['media'];
$variables['#cache']['contexts'][] = 'user.permissions';
$rel = $media
->access('edit') ? 'edit-form' : 'canonical';
$variables['url'] = $media
->toUrl($rel, [
'language' => $media
->language(),
]);
$variables += [
'preview_attributes' => new Attribute(),
'metadata_attributes' => new Attribute(),
];
$variables['status'] = $media
->isPublished();
}
}