普通网友 2017-12-16 08:55
浏览 39
已采纳

无法在tpl文件prestashop中获取产品图像

I have written a code in php which gets the product image link in prestashop. The Link I get is correct and it works but when I and add it in the image tag I get http 404 not found.

I know what the problem is but I am unable to solve. I have posted the error I am getting. I didn't post any code since I don't think the error is code related (and the code is working fine too).

The link I have of the product image:

http://localhost/prestashop/12-home_default/printed-summer-dress.jpg

This works if I just copy and paste it in my browser, But when I send it to tpl file the link doesn't get changed and it works the same as above but when I add it in the image tag i.e. <img src="product link">

I get a new link:

http://localhost/prestashop/en/module/quotation/localhost/prestashop/12-home_default/printed-summer-dress.jpg

This throws a http 404 not found error

As you can see both the links are different. I can post the code if you like. If anyone wants to know how I am getting the links, I'll post it gladly.

  • 写回答

1条回答 默认 最新

  • dongzai0020 2017-12-16 09:07
    关注

    From your error it is clear that your are trying to load the file localhost/prestashop/12-home_default/printed-summer-dress.jpg from the page http://localhost/prestashop/en/module/quotation/

    The problem with your code is, the link is getting generated as a relative link rather than an absolute link.

    To fix this, add the protocol http:// as prefix to your image path to convert it to an absolute link in your tpl.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?