Browse Source

Fix white screen when no license is present.

8.x-1.x 8.x-1.0-beta9
Alexander O'Neill 4 years ago
parent
commit
65b385503b
  1. 12
      media_attribution.module

12
media_attribution.module

@ -85,11 +85,13 @@ function media_attribution_preprocess_field__paragraph__field_attribution_author
function media_attribution_preprocess_paragraph__license_attribution__license_attribution(&$variables) {
$variables['license_prefix'] = \Drupal::translation()->translate('Licensed under');
$items = $variables['elements']['field_license']['#items'];
if (!empty($items)) {
$referencedEntity = $variables['elements']['field_license']['#items']
->first()->get('entity')->getTarget()->getValue();
$referencedEntity = $variables['elements']['field_license']['#items']
->first()->get('entity')->getTarget()->getValue();
$variables['license_link'] = $referencedEntity->get('field_license_link')->first()->view();
$variables['license_link'] = $referencedEntity->get('field_license_link')->first()->view();
}
}
/**
@ -181,4 +183,4 @@ function media_attribution_theme() {
'base hook' => 'field',
],
];
}
}

Loading…
Cancel
Save