0
<img data-bind="attr:{src: 'pub/media/catalog/product'+image_url}"/>
                <a data-bind="attr: {href: product_url}, html: name" class="product-item-link">
                </a>

Can somebody help me with this? I wanted to make the image clickable but whenever I try to put it inside the tag, the image doesn't show

2

That is not valid HTML, the img needs to be inside the a.

<a data-bind="attr: {href: product_url}, html: name" class="product-item-link">
    <img data-bind="attr:{src: 'pub/media/catalog/product'+image_url}"/>
</a>
7
  • I wanted to make the image clickable to it's product url – Adrian Paul Nov 3 '17 at 10:07
  • Yes, to do that you need to write valid HTML. Your link doesn't contain anything at all, you need to add the image to your link. – Ben Crook Nov 3 '17 at 10:09
  • The link contains the url of the product. The image doesn't show whenever I put it inside <a> tag. – Adrian Paul Nov 3 '17 at 10:10
  • You'll have to debug why, maybe it's a CSS issue? So the image does display when it's outside the A tag? – Ben Crook Nov 3 '17 at 10:27
  • I created a new <a> tag which only contains the product_url and it worked. Thanks for the help anyways. – Adrian Paul Nov 3 '17 at 10:45
0

u should try this example:

<a href="https://www.google.com/" target="popup" onclick="window.open('https://www.google.com/','popup','width=1000,height=800'); return false;"><img class="img-bank pull-left" data-bind="attr: { src: require.toUrl('images/path') }" title="Google" style="width:auto;height:28px;"></a>

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.