# Code block image link gets modified when hotlinked image is downloaded

**URL:** https://meta.discourse.org/t/code-block-image-link-gets-modified-when-hotlinked-image-is-downloaded/271571
**Category:** Bug
**Created:** [July 13, 2023, 7:09pm UTC](https://meta.discourse.org/t/code-block-image-link-gets-modified-when-hotlinked-image-is-downloaded/271571 "2023-07-13T19:09:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rahim123](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@rahim123](https://meta.discourse.org/u/rahim123)
#### Post date: [July 13, 2023, 7:09pm UTC](https://meta.discourse.org/t/code-block-image-link-gets-modified-when-hotlinked-image-is-downloaded/271571/1 "2023-07-13T19:09:56Z")

</div>

It happens when using the `![](http://something.com/image.jpg)` 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.

* * *

`![](upload://AsSrl1gma2TCpFn39yVdqjy9YTt.jpeg)`

 ![](https://global.discourse-cdn.com/meta/original/4X/f/f/9/ff91f1f3b26454ca66d6d9dbf2d9d8073a3b99d7.jpeg)

* * *

#### Original:

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/f/b/1fb6961dfb63c231bb80cade58e288827671a3ab.png)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [August 24, 2023, 1:09pm UTC](https://meta.discourse.org/t/code-block-image-link-gets-modified-when-hotlinked-image-is-downloaded/271571/3 "2023-08-24T13:09:45Z")

</div>

For the record, I faced the issue when trying to illustrate this:

> [@Remote webp images not rendering](https://meta.discourse.org/t/remote-webp-images-not-rendering/276433):
>
> Hi wave It’s pretty straightforward. Paste this in a post: հttps://media.discordapp.net/stickers/1023980063823233097.webp հttps://media.discordapp.net/stickers/1023980063823233097.png The webp image doesn’t show up: Result in post: [https://media.discordapp.net/stickers/1023980063823233097.webp](https://media.discordapp.net/stickers/1023980063823233097.webp) [image] Also, hotlinked webp aren’t downloaded to the server when download remote images to local is true.

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.

Thanks to [Unicode Utilities: Confusables](https://util.unicode.org/UnicodeJsps/confusables.jsp)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 27, 2023, 1:00pm UTC](https://meta.discourse.org/t/code-block-image-link-gets-modified-when-hotlinked-image-is-downloaded/271571/7 "2023-09-27T13:00:40Z")

</div>

> [@rahim123](#):
>
> in a code block and then using the same code outside of the code block

💯 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:

[https://github.com/discourse/discourse/pull/23682](https://github.com/discourse/discourse/pull/23682)
