function photos_theme_photos_block in Album Photos 8.4
Same name and namespace in other branches
- 7.3 photos.module \photos_theme_photos_block()
Theme photos block.
1 string reference to 'photos_theme_photos_block'
- photos_theme in ./
photos.module - Implements hook_theme().
File
- ./
photos.module, line 1160 - Implementation of photos.module.
Code
function photos_theme_photos_block($variables) {
$type = $variables['block_type'];
$images = $variables['images'];
$items = [];
// Get thumbnail size image style.
$image_sizes = \Drupal::config('photos.settings')
->get('photos_size');
$style_name = key($image_sizes);
switch ($type) {
case 'image':
foreach ($images as $image) {
$render_array = [
'#theme' => 'photos_image_html',
'#image' => $image,
'#style_name' => $style_name,
];
$items[] = $render_array;
}
break;
case 'album':
foreach ($images as $album) {
$op['attributes']['title'] = $album['node']->count ? t('A total of @title images', [
'@title' => $album['node']->count,
]) : t('Album is empty');
$url = Url::fromUri('base:node/' . $album['node']->nid, $op);
$render_array = [
'#markup' => $album['view'] . '<div class="photos_block_album_title">' . Link::fromTextAndUrl($album['node']->title, $url)
->toString() . '</div>',
];
$items[] = $render_array;
}
break;
}
$render_array = [
'#theme' => 'item_list',
'#items' => $items,
];
$content = \Drupal::service('renderer')
->render($render_array);
return $content;
}