SuperAPI AI 工具集

lando-img-placeholder

编程与开发

查看项目

更新于 10-15 21:37

技能介绍

用途:在本地 Lando PrestaShop 开发环境中,为缺失或损坏的商品图片提供静态占位图,避免页面出现破图图标。

主要能力:拦截不存在的商品图片请求并返回 img/placeholder-dev.jpg。覆盖 PrestaShop 友好图片 URL(形如 /{id}-{type}_default/...)以及传统路径 /img/p/、/img/c/、/img/m/、/img/st/。同时支持 Apache(recipe: lamp)与 nginx(recipe: lemp)。

使用方式:先读取 .lando.yml 判断 recipe。Apache 路径需创建 .lando/apache-placeholder.conf,将其中 {project} 替换为 .lando.yml 的 name 字段,下载占位图:curl -L "https://images.unsplash.com/photo-1611572789411-6240f6cea970?q=80&w=500&h=500&fit=crop" -o img/placeholder-dev.jpg,并在 services.appserver.config 下添加 vhosts: .lando/apache-placeholder.conf(合并而非覆盖),最后执行 lando rebuild -y。nginx 路径将两个 location 块加入 .lando/nginx-site.conf(需位于主 location / 之前),同样下载占位图,并确保 vhosts 指向 .lando/nginx-site.conf,再执行 lando rebuild -y。

验证:curl -I "http://{project}.lndo.site/img/p/1/test.jpg" 应返回 HTTP/1.1 200 OK。

限制:/stupload/ 在两种路径中均被排除,因为滑块/模块图片存放于此;nginx 的 try_files 仅在文件确实不存在时触发;.lando.yml 在 PS 项目中通常被 gitignore,可安全本地修改。其余细节暂未提供。