Magento 2 – How to Specify Skin Image Path in Knockout HTML Template

knockoutjsmagento-2.1magento2

I'm trying to add an icon image in the Magento_Paypal/web/template/payment/paypal-express.html template. The icon is located in web/images. I would like to use the equivalent of the following code, which works in email HTML templates, but not this particular template:

<img src="{{view url='images/icon-paypal.png'}}">

Since curly brace variables do not work in this HTML template, how do you reference an image that exists in the theme's web/images directory?

Best Answer

You need to call the function into js from the template.

require.toUrl('images/icon-paypal.png');
Related Topic