function photos_preprocess_photos_image_block in Album Photos 6.0.x
Same name and namespace in other branches
- 8.5 photos.module \photos_preprocess_photos_image_block()
- 8.4 photos.module \photos_preprocess_photos_image_block()
Implements hook_preprocess_HOOK().
File
- ./
photos.module, line 1070 - Implementation of photos.module.
Code
function photos_preprocess_photos_image_block(&$variables) {
// Prepare variables for photos_image_block.html.twig.
/** @var \Drupal\photos\Entity\PhotosImage $photos_image */
$photos_image = $variables['image']['photos_image'];
$variables['created'] = \Drupal::service('date.formatter')
->format($photos_image
->getCreatedTime(), 'short');
$variables['user_url'] = '';
if (\Drupal::moduleHandler()
->moduleExists('views')) {
$photos_album_list_view = Views::getView('photos_album');
$view_enabled = $photos_album_list_view->storage
->status();
if ($photos_album_list_view && $view_enabled) {
$views_display_options = $photos_album_list_view->storage
->get('display');
if (isset($views_display_options['page_1'])) {
$variables['user_url'] = Url::fromRoute('view.photos_album.page_1', [
'user' => $photos_image
->getOwnerId(),
])
->toString();
}
}
}
$variables['album_url'] = $photos_image
->getAlbumUrl()
->toString();
}