You are here

public function ImceFM::validateImageTypes in IMCE 8

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

Checks if all the selected items are images.

File

src/ImceFM.php, line 624

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function validateImageTypes(array $items, $silent = FALSE) {
  $regex = '/\\.(' . preg_replace('/ +/', '|', preg_quote(trim($this
    ->getConf('image_extensions', 'jpg jpeg png gif')))) . ')$/i';
  foreach ($items as $item) {
    if ($item->type === 'folder' || !preg_match($regex, $item->name)) {
      if (!$silent) {
        $this
          ->setMessage($this
          ->t('%name is not an image.', [
          '%name' => $item->name,
        ]));
      }
      return FALSE;
    }
  }
  return TRUE;
}