Skip to content

Commit

Permalink
Replace boolean cast to be able to disable frame, aspect ratio, trans…
Browse files Browse the repository at this point in the history
…parency or constrain only in view.xml

If you set frame to false in view.xml the code would cast it to true because (bool)'false' is equal to true. By using the filter_var function the cast to boolean is done correctly.
  • Loading branch information
joost-florijn-kega authored Nov 1, 2016
1 parent 8bde202 commit ed946c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/code/Magento/Catalog/Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function getQuality()
*/
public function setKeepAspectRatio($keep)
{
$this->_keepAspectRatio = (bool)$keep;
$this->_keepAspectRatio = filter_var($keep, FILTER_VALIDATE_BOOLEAN);
return $this;
}

Expand All @@ -288,7 +288,7 @@ public function setKeepAspectRatio($keep)
*/
public function setKeepFrame($keep)
{
$this->_keepFrame = (bool)$keep;
$this->_keepFrame = filter_var($keep, FILTER_VALIDATE_BOOLEAN);
return $this;
}

Expand All @@ -298,7 +298,7 @@ public function setKeepFrame($keep)
*/
public function setKeepTransparency($keep)
{
$this->_keepTransparency = (bool)$keep;
$this->_keepTransparency = filter_var($keep, FILTER_VALIDATE_BOOLEAN);
return $this;
}

Expand All @@ -308,7 +308,7 @@ public function setKeepTransparency($keep)
*/
public function setConstrainOnly($flag)
{
$this->_constrainOnly = (bool)$flag;
$this->_constrainOnly = filter_var($flag, FILTER_VALIDATE_BOOLEAN);
return $this;
}

Expand Down

0 comments on commit ed946c0

Please sign in to comment.