Domain mapping fix_srcset applies the request's mapped domain to other sites' images after switch_to_blog
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
The bug is in fix_srcset() in inc/class-domain-mapping.php, hooked on wp_calculate_image_srcset, which lacks the blog-ID check that mangle_url() already performs. Compare the two methods, then add an early return when current_mapping's blog ID differs from get_current_blog_id(). Check the filters in register_mapped_filters() for the same gap. Done when a switch_to_blog() render of another site's image gets its own srcset URLs and images on the mapped site keep the mapped domain.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- PHP
- Stars
- 219
- Forks
- 88
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 58
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Ultimate-Multisite/ultimate-multisite
-
bug hold-for-review no-auto-dispatch origin:interactive status:available
Difficulty 3/5 1-2 days Newbie friendliness 20/100
Ultimate-Multisite/ultimate-multisite#2140 ·
Maintainers usually reply within 1 day
-
enhancement hold-for-review no-auto-dispatch origin:interactive status:available
Difficulty 5/5 Over a week Newbie friendliness 15/100
Ultimate-Multisite/ultimate-multisite#2137 ·
Maintainers usually reply within 1 day
-
fix: customer site lists stop at 100 sites (BerlinDB default number)Possibly taken @superdav42 claimed this today. Openauto-dispatch bug origin:interactive status:in-review tier:standard
Ultimate-Multisite/ultimate-multisite#2136 · 5 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
fix: My Sites, Limits and Current Membership columns above 3 collapse to one column (missing grid utilities)Possibly taken @superdav42 claimed this today. Openauto-dispatch bug origin:interactive status:in-review tier:standard
Ultimate-Multisite/ultimate-multisite#2134 · 5 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
security(sso): apply mapped-domain token policy to admin-bar magic linksPossibly taken @superdav42 claimed this 1 day ago. Openauto-dispatch origin:interactive status:in-review tier:standard
Ultimate-Multisite/ultimate-multisite#2125 · 5 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in Ultimate-Multisite/ultimate-multisite
Similar issues
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
quantum-php/framework#692 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
dependencies enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day