What's the function of $imageId parameter in Magento2 Image Helper?

What is the value I should assign to it if I create a new module for new purpose?

$_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
$_imagehelper->init($_product, $imageId)->keepAspectRatio(true)->resize('400', '400');

1 Answer 1


In magento theme you might see a file view.xml


        <images module="Magento_Catalog">
            <image id="CUSTOM_IMAGE_ID" type="[IMAGE_TYPE]">

IMAGE_TYPE = small_image | thumbnail | image

CUSTOM_IMAGE_ID = Is a unique id, which we can assign to respective area or in a module.

Example : minicart image magento give name mini_cart_product_thumbnail

So now come to the your question $imageId = CUSTOM_IMAGE_ID

So in magento 2, not need to hard code image size in code that can be manageable in theme level, just go to respective theme and respective etc/view.xml

and update size (width/height/ ...) for respective image id

Image Type will help to get respective image from magento

like base image you need to resize then use type = image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.