A bug has been identified where Discourse modifies image links in code blocks when the same Markdown syntax is used outside the code block to display images. Specifically, when using  inside a code block, and later using the same syntax outside to render the image, Discourse replaces the original URL with an uploaded version (e.g., upload://...) after downloading the hotlinked image (~5 minutes later). rahim123 first reported this, and Canapin noted encountering it while documenting another issue involving remote WebP images. As a workaround, Canapin substituted the Latin ‘h’ in ‘https’ with the Armenian ‘հ’ to bypass URL detection. david confirmed the issue stems from Discourse’s logic skipping image detection in code blocks but failing to avoid replacing matching Markdown elsewhere. He added failing tests to track the bug (see PR #23682), noting the fix won’t be trivial.
It happens when using the  Markdown convention in a code block and then using the same code outside of the code block to actually display the image. It happens after about 5 minutes once Discourse downloads the hotlinked image.
For the record, I faced the issue when trying to illustrate this:
To circumvent the problem, I used հ (armenian small letter ho) instead of h (latin small letter h) in the https part. Since they are recognized as different characters, it doesn’t trigger the URL replacement.
great description. Our logic skips detecting images in a codeblock. But if there is a real image somewhere with exactly-identical markdown, then our actual find/replace code isn’t robust enough to avoid the codeblocks.
It’s not going to be trivial to fix, but for now I’ve added some failing tests so that we’re tracking the issue: