Image::__construct

public Image::__construct(ImageToolkitInterface $toolkit, $source = NULL)

Constructs a new Image object.

Parameters

\Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit: The image toolkit.

string|null $source: (optional) The path to an image file, or NULL to construct the object with no image source.

File

core/lib/Drupal/Core/Image/Image.php, line 47

Class

Image
Defines an image object to represent an image file.

Namespace

Drupal\Core\Image

Code

public function __construct(ImageToolkitInterface $toolkit, $source = NULL) {
  $this->toolkit = $toolkit;
  if ($source) {
    $this->source = $source;
    $this->getToolkit()->setSource($this->source);
    // Defer image file validity check to the toolkit.
    if ($this->getToolkit()->parseFile()) {
      $this->fileSize = filesize($this->source);
    }
  }
}
doc_Drupal
2016-10-29 09:19:10
Comments
Leave a Comment

Please login to continue.