search

Home  >  Q&A  >  body text

php - How to properly save the image src in product details?

Because the previous e-commerce BBC of Shangpai was not suitable, we rewrote a set of e-commerce ourselves and needed to migrate the original data to the new system. We encountered a problem during the migration. The product details (html text) The image address src was hard-coded before. Considering that the image should be placed on the cdn later, the src should also change with the current cdn. How to save the image src properly?

给我你的怀抱给我你的怀抱2777 days ago592

reply all(4)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 12:04:02

    Then the relative path must be saved
    cdnHost + src
    domain + src
    Even if the image is placed on the cloud, disaster recovery must be considered. If the cloud is down, normal access can still be achieved by changing the prefix of the configuration items.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 12:04:02

    @Lowky is right. Generally, pictures only save relative paths to facilitate migration. The configuration file only needs to specify the domain name, such as
    HOST=//sf.gg# // Compatible with http and https

    <img src={{HOST}}/img/xxxx.jpg>

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 12:04:02

    Do not retain the domain name, only the path behind the domain name, so that you can migrate to other domain names or clouds and modify it directly in the code. It is more convenient

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 12:04:02

    That’s not how it is

    reply
    0
  • Cancelreply