Domain mapping fix_srcset applies the request's mapped domain to other sites' images after switch_to_blog
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
问题出在 inc/class-domain-mapping.php 中的 fix_srcset(),它挂载在 wp_calculate_image_srcset 上,缺少 mangle_url() 已经执行的博客 ID 检查。请比较这两个方法,然后在 current_mapping 的博客 ID 与 get_current_blog_id() 不同时添加提前返回。同时检查 register_mapped_filters() 中的过滤器是否存在同样的缺口。当通过 switch_to_blog() 渲染其他站点的图片时能获得它们自己的 srcset URL,并且映射站点上的图片仍保持映射后的域名,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Problem
Domain_Mapping::fix_srcset() (inc/class-domain-mapping.php, hooked on wp_calculate_image_srcset) rewrites every srcset URL with replace_url() using $this->current_mapping, the mapping of the request's host. Unlike mangle_url(), which returns early when $current_mapping->get_blog_id() !== get_current_blog_id(), fix_srcset() has no site check.
So when a request for mapped site A calls switch_to_blog(B) and renders B's images, B's srcset URLs get A's domain (https://site-a.example/app/uploads/sites/B/...), while src stays correct. On a production network (2026-11-21) this was cached in Elementor's _elementor_element_cache for four posts of one site. A CDN page-URL rewriter then replaced only the upload path, leaving A's host in front of the CDN URL (https://site-a.examplehttps://cdn.example/...), so the logo, banners and product images failed to load on every page of site B.
Fix
In fix_srcset(), return $sources unchanged unless $this->current_mapping->get_blog_id() === get_current_blog_id(), matching mangle_url(). Optionally, use the mapping for the current blog instead of returning early. Check the other filters registered in register_mapped_filters() for the same missing guard.
Files Scope
- EDIT:
inc/class-domain-mapping.php(fix_srcset(), around line 705)
Verification
- On a multisite with a mapped domain for site A, request A's front end with code that runs
switch_to_blog(B); echo wp_get_attachment_image($id_on_B, 'full'); restore_current_blog();. Before the fix, srcset URLs use A's domain; after it, they use B's own URLs. - Regression: images rendered on A itself still get A's mapped domain in srcset.
aidevops.sh v3.39.189 plugin for OpenCode
- 主要语言
- PHP
- 星标
- 219
- 派生
- 88
- 平均合并
- 1 天 7 小时
- 30 天内合并 PR
- 58
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Ultimate-Multisite/ultimate-multisite 的其他 Issue
-
bug hold-for-review no-auto-dispatch origin:interactive status:available
难度 3/5 1-2 天 新手友好度 20/100
Ultimate-Multisite/ultimate-multisite#2140 ·
维护者通常 1 天内回复
-
enhancement hold-for-review no-auto-dispatch origin:interactive status:available
难度 5/5 一周以上 新手友好度 15/100
Ultimate-Multisite/ultimate-multisite#2137 ·
维护者通常 1 天内回复
-
fix: customer site lists stop at 100 sites (BerlinDB default number)可能已有人在做 @superdav42 今天认领。 未关闭auto-dispatch bug origin:interactive status:in-review tier:standard
Ultimate-Multisite/ultimate-multisite#2136 · 5 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
fix: My Sites, Limits and Current Membership columns above 3 collapse to one column (missing grid utilities)可能已有人在做 @superdav42 今天认领。 未关闭auto-dispatch bug origin:interactive status:in-review tier:standard
Ultimate-Multisite/ultimate-multisite#2134 · 5 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
security(sso): apply mapped-domain token policy to admin-bar magic links可能已有人在做 @superdav42 于 1 天前认领。 未关闭auto-dispatch origin:interactive status:in-review tier:standard
Ultimate-Multisite/ultimate-multisite#2125 · 5 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 Ultimate-Multisite/ultimate-multisite 的全部 Issue
相似的 Issue
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 78/100
quantum-php/framework#692 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
dependencies enhancement
难度 2/5 1-3 小时 新手友好度 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复