Skip to content

Instantly share code, notes, and snippets.

@vadym1930
Created June 11, 2019 20:54
Show Gist options
  • Save vadym1930/c2c8903022763a26aec6147812e4288b to your computer and use it in GitHub Desktop.
Save vadym1930/c2c8903022763a26aec6147812e4288b to your computer and use it in GitHub Desktop.
/**
* Implements hook_preprocess_HOOK().
*/
function THEME_preprocess_paragraph__button_icon(&$variables) {
$paragraph = $variables['elements']['#paragraph'];
$icon = $paragraph->get('field_icon_button')->getValue();
if (!empty($icon)) {
$entity = \Drupal::entityTypeManager()->getStorage("media")->load($icon[0]['target_id']);
$variables['button_icon'] = $entity->field_media_svg->entity->getFileUri();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment