function varbase_media_entity_embed_alter in Varbase Media 8.7
Same name and namespace in other branches
- 9.0.x varbase_media.module \varbase_media_entity_embed_alter()
Implements hook_entity_embed_alter().
File
- ./
varbase_media.module, line 791 - Contains varbase_media.module.
Code
function varbase_media_entity_embed_alter(array &$build, EntityInterface $entity, array &$context) {
// Only for entity embed review inside the CKEditor.
if (\Drupal::routeMatch()
->getRouteName() == 'entity_embed.preview') {
// Switch view mode for gallery in the CKEditor to show the Browser Teaser.
if (isset($context['data-embed-button']) && $context['data-embed-button'] == 'gallery') {
// Remove the contextual links.
if (isset($build['#contextual_links'])) {
unset($build['#contextual_links']);
}
if ($build['#context']['data-entity-embed-display'] == 'view_mode:media.full') {
$build['#context']['data-entity-embed-display'] = 'view_mode:media.browser_teaser';
$build['entity']['#view_mode'] = 'browser_teaser';
}
}
}
}