Skip to content

How to resize a custom image in Magento 2

You can resize an image with height and width. Following code shows how you do it in Magento.
we go First we create the method imageResize() in your block or you can create method in helper and pass 3 parameters with this method like imageResize($image, $width, $height).

$image: Image name only Ex: “customimage.png”
$width: It should be number for Ex: “90”
$height: It should be number for Ex: “54”

You can write the following code in template (.phtml) file to display the resized image:

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap