Magento 2: Get image url in phtml file
-
10-12-2020 - |
Solution
For example your image at:
app/code/Vendor/Module/view/frontend/web/images/demo.jpg
Use $block->getViewFileUrl()
function to get image url in phtml file like this
echo $block->getViewFileUrl('Vendor_Module::images/demo.jpg');
OTHER TIPS
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"}}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange