1

I have image tag in phtml file ..

And also i got the value of images and media url from ajax call .

How to bind it like that in ko template

<img alt="<?php echo $sizeGuideImage->getAlt() ?>" class="img-responsive" data-src-base="<?php echo $this->getMediaUrl() ?>" data-src="<479:<?php echo 'sizeguide/small/' . $sizeGuideImage->getSmallImage() ?>, <767:<?php echo 'sizeguide/medium/' . $sizeGuideImage->getMediumImage() ?>, <1399:<?php echo 'sizeguide/large/' . $sizeGuideImage->getLargeImage() ?>, >1400:<?php echo 'sizeguide/extralarge/' . $sizeGuideImage->getExtraLargeImage() ?>" />
1

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

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

Addition: This can be written in a cleaner way:

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

Source How to specify skin image path in Knockout HTML template?

  • But i need to frame img tag like data-src="<479:sizeguide/small/bra_size_calculator_365-x-228-30kb_1.jpg, <767:sizeguide/medium/bra_size_calculato_507-x-317-40-kb_1.jpg" – Mano M Sep 21 '18 at 13:23

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.