Magento 2 – Display Image in Module Template phtml File

magento-2.0phtml

I want to display an image in the module template file. When somebody installs my module, he can see that image. Can I store my images inside my module directory or not?

Best Answer

Yes you can store images in your module web directories depending on the area of your templates. The path is: Vendor/Module/view/{frontend|adminhtml}/web/images/

Then in your *.phtml files you can display the image:

<img src="<?php echo $this->getViewFileUrl('Vendor_Module::images/image.png'); ?>" />