You are here

public function ImceFM::validateDimensions in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/ImceFM.php \Drupal\imce\ImceFM::validateDimensions()

Validates min/max image dimensions.

File

src/ImceFM.php, line 604

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function validateDimensions(array $items, $width, $height, $silent = FALSE) {

  // Check min dimensions.
  if ($width < 1 || $height < 1) {
    return FALSE;
  }

  // Check max dimensions.
  $maxwidth = $this
    ->getConf('maxwidth');
  $maxheight = $this
    ->getConf('maxheight');
  if ($maxwidth && $width > $maxwidth || $maxheight && $height > $maxheight) {
    if (!$silent) {
      $this
        ->setMessage($this
        ->t('Image dimensions must be smaller than %dimensions pixels.', [
        '%dimensions' => $maxwidth . 'x' . $maxwidth,
      ]));
    }
    return FALSE;
  }
  return TRUE;
}