You are here

public static function FileManagement::isImage in File Management 8

Checks if a given file is an image.

Parameters

\Drupal\file\FileInterface $file: The file entity to check.

Return value

bool Whether the file is an image or not.

1 call to FileManagement::isImage()
FileManagement::getFileInformation in src/FileManagement.php
Generates a render array with file information from the given file entity.

File

src/FileManagement.php, line 114

Class

FileManagement
File Management helper methods.

Namespace

Drupal\file_management

Code

public static function isImage(FileInterface $file) {
  if (empty(file_validate_is_image($file))) {
    return TRUE;
  }
  if ($file
    ->getMimeType() === 'image/svg+xml') {
    return TRUE;
  }
  return FALSE;
}