You are here

public function Photos::photoCalculateAspectRatio in Flickr 8

Calculate aspect.

Parameters

int $width: Width.

int $height: Height.

Return value

string Return aspect.

1 call to Photos::photoCalculateAspectRatio()
Photos::photoGetSize in src/Service/Photos.php
Get Photo Size.

File

src/Service/Photos.php, line 200

Class

Photos
Class Photos.

Namespace

Drupal\flickr\Service

Code

public function photoCalculateAspectRatio($width, $height) {
  $aspectRatio = (int) $width / (int) $height;
  if ($aspectRatio > 1) {

    // Image is Landscape.
    return 'landscape';
  }
  if ($aspectRatio < 1) {

    // Image is Portrait.
    return 'portrait';
  }
  else {

    // Image is Square.
    return 'square';
  }
}