-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report
Description
Steps to reproduce
- In the current theme's view.xml file, add
<frame>false</frame>
to a specific image type as instructed in the docs: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-images.html . This image should also have awidth
andheight
setting andaspect_ratio
set to true. For example:
<image id="category_page_grid" type="small_image">
<width>460</width>
<height>460</height>
<aspect_ratio>true</aspect_ratio>
<frame>false</frame>
</image>
- Clear image cache, refresh a page with this specific image type.
Expected result
- Image should keep its aspect ratio, not have any added white frame, and size should be within the configured width and height.
Cause:
The value from view.xml is passed to the method \Magento\Catalog\Model\Product\Image::setKeepFrame – which casts the string "false" to the boolean true. Therefore, it is not possible to set keep_frame to false from within the view.xml.
/**
* @param bool $keep
* @return $this
*/
public function setKeepFrame($keep)
{
$this->_keepFrame = (bool)$keep;
return $this;
}
After creating a plugin to convert the string value to an integer (which properly casts to a boolean), the image frame is not added.
public function beforeSetKeepFrame($image, $keep)
{
if (is_string($keep)) {
$keep = (strtolower($keep) === 'true') ? 1 : 0;
}
return [$keep];
}
Yonn-Trimoreau, markdavies, medinadato, darinda, ennostuurman and 1 moredangelion
Metadata
Metadata
Assignees
Labels
Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report