function ImageFactory::get
Same name in other branches
- 9 core/lib/Drupal/Core/Image/ImageFactory.php \Drupal\Core\Image\ImageFactory::get()
- 8.9.x core/lib/Drupal/Core/Image/ImageFactory.php \Drupal\Core\Image\ImageFactory::get()
- 10 core/lib/Drupal/Core/Image/ImageFactory.php \Drupal\Core\Image\ImageFactory::get()
Constructs a new Image object.
Normally, the toolkit set as default in the admin UI is used by the factory to create new Image objects. This can be overridden through \Drupal\Core\Image\ImageInterface::setToolkitId() so that any new Image object created will use the new toolkit specified. Finally, a single Image object can be created using a specific toolkit, regardless of the current factory settings, by passing its plugin ID in the $toolkit_id argument.
Parameters
string|null $source: (optional) The path to an image file, or NULL to construct the object with no image source.
string|null $toolkit_id: (optional) The ID of the image toolkit to use for this image, or NULL to use the current toolkit.
Return value
\Drupal\Core\Image\ImageInterface An Image object.
See also
File
-
core/
lib/ Drupal/ Core/ Image/ ImageFactory.php, line 83
Class
- ImageFactory
- Provides a factory for image objects.
Namespace
Drupal\Core\ImageCode
public function get($source = NULL, $toolkit_id = NULL) {
$toolkit_id = $toolkit_id ?: $this->toolkitId;
return new Image($this->toolkitManager
->createInstance($toolkit_id), $source);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.