2

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?

4

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? – LM_Fielding Jun 5 '16 at 14:10
  • Vendor_Module::...? – LM_Fielding Jun 9 '16 at 13:11
  • 1
    are you asking that the image is in the Vendor module ? – user40382 Jun 13 '16 at 12:17
  • 1
    Yes, that's what I'm asking. – LM_Fielding Jun 13 '16 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.