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

无法在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.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?