普通网友 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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘