1

The image help can resize the image, but I don't understand the constrainOnly parameter in it. What is the function of ->constrainOnly(true) and ->constrainOnly(false)?

code example

return $this->_imageHelper
        ->init($product,'category_page_list')
        ->constrainOnly(FALSE)
        ->keepAspectRatio(TRUE)
        ->keepFrame(FALSE)
        ->resize(240, 300)

1 Answer 1

3
->constrainOnly(true)

This will not resize an image that is smaller than the dimensions inside the resize() part. Default value is true in Magento 2.1.

->constrainOnly(false)

This will resize an image that is smaller than the dimensions inside the resize() part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.