How to resize custom image in magento 2?

We can resize the custom image in Magento 2 by simple coding snippet. Many times we need to resize images in Magento 2 for a custom module or like category images.

For Image resize, we need to crate Block file under the module and called function under the template file.

We have created a getResizeImage() function under the block file and pass the first parameter as actual image name only, the second parameter will be width and the third parameter is height.

For Product image resize refer blog, Product image resize

Called from Template file,

You got the output as 150×150 Resize image.

 

 

Leave a Reply

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