I have tried this which gives me the images url for my theme, which does not have the images that are located in my module/view/frontend/web/images folder.

return $this->getViewFileUrl($image_path);

Where do static images go inside a module, and how can they be used in a block?

1 Answer 1


You have to change the destination of your images and then you would be able to fetch static images

  1. Put your image on Your Magento 2 Path: /app/design/frontend///web/images
  2. Use this code to call the image in phtml file
<?php echo $block->getViewFileUrl('images/demo.jpg'); ?>
  • 1
    That is what I'm doing now, however it doesn't seem like best practise. Why should a module's images and display depend upon the theme? Jun 5, 2016 at 14:10
  • Vendor_Module::...? Jun 9, 2016 at 13:11
  • 1
    are you asking that the image is in the Vendor module ?
    – user40382
    Jun 13, 2016 at 12:17
  • 1
    Yes, that's what I'm asking. Jun 13, 2016 at 14:54

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.