You are here

public function TestToolkit::parseFile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php \Drupal\image_test\Plugin\ImageToolkit\TestToolkit::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/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php, line 139
Contains \Drupal\image_test\Plugin\ImageToolkit\TestToolkit.

Class

TestToolkit
Defines a Test toolkit for image manipulation within Drupal.

Namespace

Drupal\image_test\Plugin\ImageToolkit

Code

public function parseFile() {
  $this
    ->logCall('parseFile', func_get_args());
  $data = @getimagesize($this
    ->getSource());
  if ($data && in_array($data[2], static::supportedTypes())) {
    $this
      ->setType($data[2]);
    $this->width = $data[0];
    $this->height = $data[1];
    return TRUE;
  }
  return FALSE;
}