You are here

public function GDToolkit::parseFile in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::parseFile()

Determines if a file contains a valid image.

Drupal supports GIF, JPG and PNG file formats when used with the GD toolkit, and may support others, depending on which toolkits are installed.

Return value

bool TRUE if the file could be found and is an image, FALSE otherwise.

Overrides ImageToolkitInterface::parseFile

File

core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php, line 278

Class

GDToolkit
Defines the GD2 toolkit for image manipulation within Drupal.

Namespace

Drupal\system\Plugin\ImageToolkit

Code

public function parseFile() {
  $data = @getimagesize($this
    ->getSource());
  if ($data && in_array($data[2], static::supportedTypes())) {
    $this
      ->setType($data[2]);
    $this->preLoadInfo = $data;
    return TRUE;
  }
  return FALSE;
}