diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index b88a220..21b35bd 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -26,7 +26,7 @@ class GDToolkit extends ImageToolkitBase { * * @var resource */ - protected $resource; + protected $resource = NULL; /** * Image type represented by a PHP IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG). @@ -40,7 +40,7 @@ class GDToolkit extends ImageToolkitBase { * * @var array */ - protected $preLoadInfo; + protected $preLoadInfo = NULL; /** * Sets the GD image resource. @@ -51,8 +51,8 @@ class GDToolkit extends ImageToolkitBase { * @return $this */ public function setResource($resource) { - if (isset($this->preLoadInfo)) { - unset($this->preLoadInfo); + if ($this->preLoadInfo) { + $this->preLoadInfo = NULL; } $this->resource = $resource; return $this; @@ -65,7 +65,7 @@ public function setResource($resource) { * The GD image resource, or NULL if not available. */ public function getResource() { - if (!isset($this->resource)) { + if (!$this->resource) { $this->load(); } return $this->resource; @@ -110,8 +110,8 @@ protected function load() { $function = 'imagecreatefrom' . image_type_to_extension($this->getType(), FALSE); if (function_exists($function) && $resource = $function($this->getImage()->getSource())) { + $this->setResource($resource); if (imageistruecolor($resource)) { - $this->setResource($resource); return TRUE; } else { @@ -133,7 +133,7 @@ protected function load() { * {@inheritdoc} */ public function isValid() { - return isset($this->preLoadInfo) || isset($this->resource); + return ((bool) $this->preLoadInfo || (bool) $this->resource); } /** @@ -246,7 +246,7 @@ public function createTmp($type, $width, $height) { * {@inheritdoc} */ public function getWidth() { - if (isset($this->preLoadInfo)) { + if ($this->preLoadInfo) { return $this->preLoadInfo[0]; } elseif ($res = $this->getResource()) { @@ -261,7 +261,7 @@ public function getWidth() { * {@inheritdoc} */ public function getHeight() { - if (isset($this->preLoadInfo)) { + if ($this->preLoadInfo) { return $this->preLoadInfo[1]; } elseif ($res = $this->getResource()) {