You are here

function photos_preprocess_search_result in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 photos.module \photos_preprocess_search_result()

Implements hook_preprocess_search_result().

File

./photos.module, line 1424
Implementation of photos.module.

Code

function photos_preprocess_search_result(&$variables) {
  if ($variables['plugin_id'] == 'photos_image_search') {

    // Add search_result_image display to snippet if enabled.
    $search_image_view_display = \Drupal::entityTypeManager()
      ->getStorage('entity_view_display')
      ->load('photos_image.photos_image.search_result_image');
    if ($search_image_view_display && $search_image_view_display
      ->status()) {
      $viewBuilder = \Drupal::entityTypeManager()
        ->getViewBuilder('photos_image');
      $renderImage = $viewBuilder
        ->view($variables['result']['photos_image'], 'search_result_image');
      $variables['snippet'] = [
        '#markup' => \Drupal::service('renderer')
          ->render($renderImage) . \Drupal::service('renderer')
          ->render($variables['snippet']),
      ];
    }
  }
}