{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/4622","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/4622/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/4622/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/4622/events","html_url":"https://github.com/magento/magento2/issues/4622","id":156186505,"number":4622,"title":"Setting image keep frame to false in theme's view.xml does not work","user":{"login":"brendanmckeown","id":1933201,"avatar_url":"https://avatars.githubusercontent.com/u/1933201?v=3","gravatar_id":"","url":"https://api.github.com/users/brendanmckeown","html_url":"https://github.com/brendanmckeown","followers_url":"https://api.github.com/users/brendanmckeown/followers","following_url":"https://api.github.com/users/brendanmckeown/following{/other_user}","gists_url":"https://api.github.com/users/brendanmckeown/gists{/gist_id}","starred_url":"https://api.github.com/users/brendanmckeown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendanmckeown/subscriptions","organizations_url":"https://api.github.com/users/brendanmckeown/orgs","repos_url":"https://api.github.com/users/brendanmckeown/repos","events_url":"https://api.github.com/users/brendanmckeown/events{/privacy}","received_events_url":"https://api.github.com/users/brendanmckeown/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magento/magento2/labels/CS","name":"CS","color":"fad8c7"}],"state":"open","locked":false,"assignee":{"login":"slavvka","id":9741905,"avatar_url":"https://avatars.githubusercontent.com/u/9741905?v=3","gravatar_id":"","url":"https://api.github.com/users/slavvka","html_url":"https://github.com/slavvka","followers_url":"https://api.github.com/users/slavvka/followers","following_url":"https://api.github.com/users/slavvka/following{/other_user}","gists_url":"https://api.github.com/users/slavvka/gists{/gist_id}","starred_url":"https://api.github.com/users/slavvka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavvka/subscriptions","organizations_url":"https://api.github.com/users/slavvka/orgs","repos_url":"https://api.github.com/users/slavvka/repos","events_url":"https://api.github.com/users/slavvka/events{/privacy}","received_events_url":"https://api.github.com/users/slavvka/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-05-23T01:49:41Z","updated_at":"2016-06-01T15:07:28Z","closed_at":null,"body":"Steps to reproduce\r\n--\r\n1. 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 a `width` and `height` setting and `aspect_ratio` set to true. For example:\r\n```\r\n            <image id=\"category_page_grid\" type=\"small_image\">\r\n                <width>460</width>\r\n                <height>460</height>\r\n                <aspect_ratio>true</aspect_ratio>\r\n                <frame>false</frame>\r\n            </image>\r\n```\r\n2. Clear image cache, refresh a page with this specific image type.\r\n\r\nExpected result\r\n--\r\n1. Image should keep its aspect ratio, not have any added white frame, and size should be within the configured width and height.\r\n\r\n<img width=\"474\" alt=\"screen shot 2016-05-22 at 9 41 50 pm\" src=\"https://cloud.githubusercontent.com/assets/1933201/15458318/1b586c34-2066-11e6-9efc-734a02060840.png\">\r\n\r\n\r\nActual result\r\n--\r\n1. Image is forced to width and height with white frame, and does not keep original aspect ratio.\r\n\r\n<img width=\"476\" alt=\"screen shot 2016-05-22 at 9 42 15 pm\" src=\"https://cloud.githubusercontent.com/assets/1933201/15458320/1f567ce0-2066-11e6-9258-66b9adf45bff.png\">\r\n\r\n\r\nCause:\r\nThe 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. \r\n```\r\n    /**\r\n     * @param bool $keep\r\n     * @return $this\r\n     */\r\n    public function setKeepFrame($keep)\r\n    {\r\n        $this->_keepFrame = (bool)$keep;\r\n        return $this;\r\n    }\r\n```\r\nAfter creating a plugin to convert the string value to an integer (which properly casts to a boolean), the image frame is not added.\r\n\r\n```\r\n    public function beforeSetKeepFrame($image, $keep)\r\n    {\r\n        if (is_string($keep)) {\r\n            $keep = (strtolower($keep) === 'true') ? 1 : 0;\r\n        }\r\n        return [$keep];\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/223022866","html_url":"https://github.com/magento/magento2/issues/4622#issuecomment-223022866","issue_url":"https://api.github.com/repos/magento/magento2/issues/4622","id":223022866,"user":{"login":"Yonn-Trimoreau","id":5746666,"avatar_url":"https://avatars.githubusercontent.com/u/5746666?v=3","gravatar_id":"","url":"https://api.github.com/users/Yonn-Trimoreau","html_url":"https://github.com/Yonn-Trimoreau","followers_url":"https://api.github.com/users/Yonn-Trimoreau/followers","following_url":"https://api.github.com/users/Yonn-Trimoreau/following{/other_user}","gists_url":"https://api.github.com/users/Yonn-Trimoreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Yonn-Trimoreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yonn-Trimoreau/subscriptions","organizations_url":"https://api.github.com/users/Yonn-Trimoreau/orgs","repos_url":"https://api.github.com/users/Yonn-Trimoreau/repos","events_url":"https://api.github.com/users/Yonn-Trimoreau/events{/privacy}","received_events_url":"https://api.github.com/users/Yonn-Trimoreau/received_events","type":"User","site_admin":false},"created_at":"2016-06-01T15:07:28Z","updated_at":"2016-06-01T15:07:28Z","body":"+1"}}
{"actor":{"display_login":"Yonn-Trimoreau"}}