diff --git a/src/Phact/Orm/Fields/ImageField.php b/src/Phact/Orm/Fields/ImageField.php index e01ebe5..ef74e57 100644 --- a/src/Phact/Orm/Fields/ImageField.php +++ b/src/Phact/Orm/Fields/ImageField.php @@ -128,13 +128,14 @@ public function sizePath($prefix) return $this->getStorage()->getPath($path); } - public function afterSave() + public function setValue($value, $aliasConfig = NULL) { - parent::afterSave(); - - if (!empty($this->sizes)) { + $createSizes = !(($value instanceof StorageFile) && $value->equalsTo($this->getAttribute())); + $attribute = parent::setValue($value, $aliasConfig); + if ($createSizes) { $this->createSizes(); } + return $attribute; } public function deleteOld() @@ -149,7 +150,6 @@ public function deleteOld() } } - public function createSizes() { foreach ($this->sizes as $sizeName => $params) { @@ -199,7 +199,6 @@ public function sizeContain(BoxInterface $box, $imageInstance) return $imageInstance->thumbnail($box, ManipulatorInterface::THUMBNAIL_INSET); } - /** * @param $sizeName * @param $source ImageInterface @@ -272,7 +271,6 @@ protected function getSizeBox(ImageInterface $image, $sizeParams) } return $box; - } protected function preparePrefixSize($prefix) @@ -280,7 +278,6 @@ protected function preparePrefixSize($prefix) return rtrim($prefix, '_') . '_'; } - public function getImagine() { if ($this->_imagine === null) {