So here's the deal. Our image path code sucks. It's bad. It's no one's fault, it's just the result of years of special cases and new use cases that never got a full rewrite of love they need. I know this code pretty well and still spent today git reverting my changes getting nowhere. This is such a great example of tech debt it's ridiculous.
Ultimately, we need this to work and work well for so many use cases that it's rather complex, some examples:
- Local (where we don't have all the per-site domains, making relative painful)
- Dev (which we may or may not toggle the CDN, making caching paths painful)
- Dev (also a problem for testing branches on various dev domains and builds)
- Prod (which may or may not have HTTPS, making caching paths painful)
- Meta Stack Exchange (which doesn't use the CDN, in case the CDN is the problem being reported)
- Emails (which don't support scheme/protocol-relative URLs, or anything relative in general)
- Images vs. other content like
/Img paths (shared vs. global)
- Beta sites, which share image paths but not content paths
- Site settings across all these tiers to toggle various pathing (cache pain again)
It's such a royal cluster of situations we have to support that the code reflects it at this point. I think we can clean that up - and in order to move our meta sites and deploy full HTTPS support, I need to do that cleanup. But this isn't a quick fix and today was an exercise in frustration proving that.
Tomorrow morning I won't be writing any code. Instead, I'll be documenting all of the above and the walls and edge cases of each scenario so we can hopefully come up with something far cleaner and DRYer than exists today. Maybe we can just share that document out to everyone since it's an interesting case of crazy.
Sorry for the breaks today, we'd never do such intentionally. I'm backing away and we'll do heavy analysis before pushing any more code simplifications here. I've already got developer views comparing all of these path variants across all of the tiers as a starting point.
Edit: For the why this broke things. I combined 2 of the use cases, which were covered and fine in one section of emails but alas there was a copy of email code which didn't contain the same logic, so swapping some image properties beneath it hosed that case - and that's what users saw. For the meta.stackexchange.com images, they are relative (for the reasons above), and broke in places not called with a
Site.Url() method we have, which has the effect of rendering an absolute URL for stackexchange.com...which does not have that relative image. It was relative to the Q&A site root, a different web application.