I'm trying to add an image to my first module can someone tell me how I cando this I am new to Magento

this is phtml file

<h2>Hello world</h2>

module is in


enter image description here

This is my directory structure of Helloworld Module

  • Let me know if you have any issue – Prince Patel Aug 19 '17 at 16:26
  • I add images like above but its not working sir. i cleared my cache but not working – Hemal Aug 19 '17 at 16:34
  • What is the error or what is display in image URL? – Prince Patel Aug 19 '17 at 16:48
  • nothing show just text – Hemal Aug 19 '17 at 16:53
  • is there any other solution – Hemal Aug 19 '17 at 17:19

For example your image at:


Use $block->getViewFileUrl() function to get image url in phtml file like this

echo $block->getViewFileUrl('Vendor_Module::images/demo.jpg'); 

If you using phtml file add an image, CSS and js use $block->getViewFileUrl() and if you working on block use this{{view url="images/IMG_7300.JPG"}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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