php - How to properly save the image src in product details?
给我你的怀抱
给我你的怀抱 2017-05-16 12:02:02
0
4
589

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?

给我你的怀抱
给我你的怀抱

reply all(4)
漂亮男人

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.

滿天的星座

@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>

曾经蜡笔没有小新

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

伊谢尔伦

That’s not how it is

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template