You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I setup entity_embed on my website to embed media entities (documents for now).
I noticed that nothing gets displayed when we are in edit mode (admin theme active - seven) and attempt to display a media entity that uses a pattern defined in oe_theme (the file pattern here).
I haven't seen any entity_embed integration in OE modules so far. Perhaps you plan to do it later?
One solution would be to move all UI Patterns oe_theme_helper I guess ?
Anyway here is a workaround I used to format the embedded view mode of documents:
/**
* Preprocessor for Media Document embedded.
*/
function mymodule_preprocess_media__document__embedded(array &$variables) {
// @TODO The "file" pattern currently defined in oe_theme is not found when
// we are in edit mode with the admin theme active.
// So we abort when we're on the admin theme
// But this needs to be fixed somehow...
$admin_theme = \Drupal::config('system.theme')->get('admin');
$current_theme = \Drupal::theme()->getActiveTheme()->getName();
if ($admin_theme === $current_theme) {
return;
}
/** @var \Drupal\media\Entity\Media $media_entity */
$media_entity = $variables['media'];
$media_source = $media_entity->getSource();
$source_field_name = $media_source->getConfiguration()['source_field'];
/** @var \Drupal\file\Entity\File $file_entity */
$file_entity = $media_entity->get($source_field_name)->entity;
$file_value_object = FileValueObject::fromFileEntity($file_entity);
$file_value_object->setTitle($media_entity->getName());
$variables['content'] = [
'#type' => 'pattern',
'#id' => 'file',
'#variant' => '',
'#fields' => [
'button_label' => t('Download'),
'file' => $file_value_object,
],
];
}
Any advice on this is welcome.
The text was updated successfully, but these errors were encountered:
Hello,
I setup entity_embed on my website to embed media entities (documents for now).
I noticed that nothing gets displayed when we are in edit mode (admin theme active - seven) and attempt to display a media entity that uses a pattern defined in oe_theme (the file pattern here).
I haven't seen any entity_embed integration in OE modules so far. Perhaps you plan to do it later?
One solution would be to move all UI Patterns oe_theme_helper I guess ?
Anyway here is a workaround I used to format the embedded view mode of documents:
Any advice on this is welcome.
The text was updated successfully, but these errors were encountered: