- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019
08:33 AM
09-16-2019
08:33 AM
Some product images are the wrong size
For every couple of products that one of our customers adds to their site one of them will upload with a single incorrect image. The image source file has the same dimensions as the two products next to it in the photo below, but when uploaded, Magento is adding a white border on that particular one. We are running magento 2.3.2.
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019
11:59 AM
09-16-2019
11:59 AM
Re: Some product images are the wrong size
Hello @DTF Digital
You can try following code for resize the product images in magento 2.
First of all, you need to call helper file. Magento\Catalog\Helper\Image to resize product image.
$_product = $productObject; // Your Product Object
$_imageHelper = $this->helper('Magento\Catalog\Helper\Image');
$_productImage = $_imageHelper->init($_product, 'thumbnail', ['type'=>'thumbnail'])
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->resize('256','128')
->getUrl();
If my answer is useful, please Accept as Solution & give Kudos
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019
01:53 PM
09-16-2019
01:53 PM
Re: Some product images are the wrong size
Thanks for your reply, unfortunately resizing the image isn't the problem, it's just the odd image that's scaled incorrectly, for a so far unknown reason.