Skip to content

Commit

Permalink
addresses steve's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aheaphy committed Dec 22, 2023
1 parent 4709919 commit e11a510
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions web/themes/custom/nysenate_theme/nysenate_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,18 @@ function nysenate_theme_preprocess_block_content__featured_legislation(&$variabl
->getMicrosite($senator);
$variables['senator_link'] = $senator_link;

$variables['senator_image'] = NULL;
if ($senator->hasField('field_member_headshot') && !$senator->get('field_member_headshot')->isEmpty()) {
$mid = $senator->field_member_headshot->target_id ?? 0;
$entity_manager = \Drupal::entityTypeManager();
$mid = $senator->field_member_headshot->target_id;
$media_image = $entity_manager->getStorage('media')->load($mid);
$variables['senator_image'] = !empty($media_image) ? $entity_manager->getViewBuilder('media')->view($media_image, '160x160') : NULL;
try {

$media_image = \Drupal::entityTypeManager()->getStorage('media')->load($mid);
}
catch (\Throwable) {
$media_image = NULL;
}
$variables['senator_image'] = $media_image ? $entity_manager->getViewBuilder('media')->view($media_image, '160x160') : NULL;
}
}

Expand Down

0 comments on commit e11a510

Please sign in to comment.