You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
855 B

<?php
/**
* Implements hook_theme_suggestions_page_alter().
*/
function lmmi_journal_theme_suggestions_page_alter(array &$suggestions, array $variables) {
if ($node = \Drupal::routeMatch()->getParameter('node')) {
$suggestions[] = 'page__' . $node->bundle();
}
}
/**
* Implements hook_preprocess_node().
* @param $variables
*/
function lmmi_journal_preprocess_node(&$variables) {
$node = $variables['elements']['#node'];
$bundle = $node->bundle();
if ($bundle == 'journal_article' && $variables['elements']['#view_mode'] == 'hero') {
$hero_image = $node->get('field_article_highlight_image')->getValue();
if (!empty($hero_image)) {
$entity = Media::load($hero_image[0]['target_id']);
$variables['hero_image'] = ImageStyle::load('article_hero')->buildUrl($entity->field_image->entity->getFileUri());
}
}
}