Skip to content

Commit

Permalink
Fixed unnecessary resize
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOkulov committed Jun 1, 2020
1 parent fe931f0 commit baa5046
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Phact/Orm/Fields/ImageField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -149,7 +150,6 @@ public function deleteOld()
}
}


public function createSizes()
{
foreach ($this->sizes as $sizeName => $params) {
Expand Down Expand Up @@ -199,7 +199,6 @@ public function sizeContain(BoxInterface $box, $imageInstance)
return $imageInstance->thumbnail($box, ManipulatorInterface::THUMBNAIL_INSET);
}


/**
* @param $sizeName
* @param $source ImageInterface
Expand Down Expand Up @@ -272,15 +271,13 @@ protected function getSizeBox(ImageInterface $image, $sizeParams)
}

return $box;

}

protected function preparePrefixSize($prefix)
{
return rtrim($prefix, '_') . '_';
}


public function getImagine()
{
if ($this->_imagine === null) {
Expand Down

0 comments on commit baa5046

Please sign in to comment.