protected function PhotoswipePreprocessProcessor::getRandarableImage in PhotoSwipe 3.x
Build randarable array for given image.
Parameters
array $variables: An associative array containing image variables.
Return value
array Randarable array contains the image.
1 call to PhotoswipePreprocessProcessor::getRandarableImage()
- PhotoswipePreprocessProcessor::preprocess in src/
PhotoswipePreprocessProcessor.php - Preprocess image.
1 method overrides PhotoswipePreprocessProcessor::getRandarableImage()
- PhotoswipeResponsivePreprocessProcessor::getRandarableImage in src/
PhotoswipeResponsivePreprocessProcessor.php - Build randarable array for given image.
File
- src/
PhotoswipePreprocessProcessor.php, line 211
Class
- PhotoswipePreprocessProcessor
- Preprocess photoswipe images.
Namespace
Drupal\photoswipeCode
protected function getRandarableImage(array $variables) {
$image = [
'#theme' => 'image_style',
'#uri' => $this->imageDTO
->getUri(),
'#alt' => $this->imageDTO
->getAlt(),
'#title' => $this->imageDTO
->getTitle(),
'#attributes' => $this->imageDTO
->getItem()->_attributes,
'#style_name' => $this->imageDTO
->getSettings()['photoswipe_node_style'],
];
if (isset($variables['delta']) && $variables['delta'] === 0 && !empty($this->imageDTO
->getSettings()['photoswipe_node_style_first'])) {
$image['#style_name'] = $this->imageDTO
->getSettings()['photoswipe_node_style_first'];
}
// Render as a standard image if an image style is not given.
if (empty($image['#style_name']) || $image['#style_name'] === 'hide') {
$image['#theme'] = 'image';
}
return $image;
}