You are here

protected function PhotoswipePreprocessProcessor::setDimensions in PhotoSwipe 3.x

Set image dimensions.

Parameters

array $image: Randarable array of image.

1 call to PhotoswipePreprocessProcessor::setDimensions()
PhotoswipePreprocessProcessor::preprocess in src/PhotoswipePreprocessProcessor.php
Preprocess image.

File

src/PhotoswipePreprocessProcessor.php, line 261

Class

PhotoswipePreprocessProcessor
Preprocess photoswipe images.

Namespace

Drupal\photoswipe

Code

protected function setDimensions(array &$image) {

  // The image.factory service will check if our image is valid.
  $image_file = $this->imageFactory
    ->get($this->imageDTO
    ->getUri());
  if ($image_file
    ->isValid()) {
    $image['#width'] = $image_file
      ->getWidth();
    $image['#height'] = $image_file
      ->getHeight();
    $this->imageDTO
      ->setDimensions([
      ImageDTO::HEIGHT => $image_file
        ->getHeight(),
      ImageDTO::WIDTH => $image_file
        ->getWidth(),
    ]);
  }
}