ques-aWj6e90q

Search A2Z 24

Question : Magento 2: Get image url in template file

X

How I can Add a static image on PHTML page in Magento2?

In Magento 1.x it was possible using

$this->getSkinUrl('images/xyz.jpg')
asked February 9, 2017

1 Answers

Dispalying 1 to 1 of 1 |

Step 1) Put your image on Your Magento 2 Path: /app/design/frontend/< Vendor >/< theme >/web/images

Step 2) Use this code to call the image in phtml file

<?php echo $block->getViewFileUrl('images/xyz.jpg'); ?>

Note : If you need an asset of a specifc module, you can prefix it with '::':

<?php  $this->getViewFileUrl('Vendor_Module::img/spinner.gif'); ?>
See comments (0) | Comment
Answered 2 Years ago
Dispalying 1 to 1 of 1 |

Write your Answer write code <pre class="brush: xml">---code---</pre>

Login as a member to access answering block !! click-here
loading...

×