# Replacing remote images with local uploaded images issue

**URL:** https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622
**Category:** Bug
**Created:** [June 3, 2015, 9:31pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622 "2015-06-03T21:31:08Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 9:31pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/1 "2015-06-03T21:31:08Z")

</div>

reprocase:

- insert an image (using an external url) in a post using a link reference.
- wait for the system to replace the external url with an uploaded copy.
- the url is replaced by an html `<img>` tag.

bug: the url in the refence il also replaced with the html `<img>` tag.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 3, 2015, 9:39pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/3 "2015-06-03T21:39:17Z")

</div>

I’m not following.

Are you saying you want the link to an image in the post to _not_ be changed into the image?

That is the expected behavior.

If you want the link to stay a link don’t put it on it’s own line  
Or enclose it in backticks so it gets rendered as a text URL

---

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 9:46pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/4 "2015-06-03T21:46:08Z")

</div>

No @Mittineague, this is not the point.

Maybe this gist will help:

> <https://gist.github.com/evantill/845900e245e6c9bf7c56>

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 3, 2015, 9:50pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/5 "2015-06-03T21:50:13Z")

</div>

Ahh, you’re not using the correct MarkDown syntax for links.

> **[Links - Daring Fireball: Markdown Syntax Documentation](https://daringfireball.net/projects/markdown/syntax#link)**
>
> Note: This document is itself written using Markdown; you can see the source for it by adding ‘.text’ to the URL.

It should be  
[link text here] (URL here)

\* with the URL in parentheses not as HTML or a “raw” URL

EDIT  
:d’oh:  
Sorry, I misunderstood what you’re wanting to do. Not a link, but

> **[Images - Daring Fireball: Markdown Syntax Documentation](https://daringfireball.net/projects/markdown/syntax#img)**
>
> Note: This document is itself written using Markdown; you can see the source for it by adding ‘.text’ to the URL.

> Reference-style image syntax looks like this:

> ![Alt text][id]

> Where “id” is the name of a defined image reference. Image references are defined using syntax identical to link references:

> [id]: url/to/image “Optional title attribute”

---

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 9:56pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/6 "2015-06-03T21:56:41Z")

</div>

Let try my example on meta:

Ou est Charlie ?

 ![Char](https://global.discourse-cdn.com/meta/original/4X/e/a/0/ea043c09727c9c9d32b1c841169773f94f3f0abd.jpeg)

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 3, 2015, 9:59pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/7 "2015-06-03T21:59:15Z")

</div>

Let me try

```plaintext
![Char](upload://xocND7GGs7QsjrG1UNfHRGCJsZf.jpeg)

```

 ![Char](https://global.discourse-cdn.com/meta/original/4X/e/a/0/ea043c09727c9c9d32b1c841169773f94f3f0abd.jpeg)

Same thing happens

```plaintext
<img src="upload://xocND7GGs7QsjrG1UNfHRGCJsZf.jpeg" alt="Char" height="308" width="292">

```

---

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 10:03pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/8 "2015-06-03T22:03:22Z")

</div>

Did you confirm this is a bug ?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 3, 2015, 10:04pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/9 "2015-06-03T22:04:30Z")

</div>

I don’t know. What is the expected behavior?

---

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 10:12pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/10 "2015-06-03T22:12:15Z")

</div>

expected result shoud be :

```
exemple here :

Ou est Charlie ?

![Char][Charlie]

[Charlie]: /uploads/default/original/1X/70bdb0afec7b129ae882d21587d82d09c2f0a6c3.png

```

and not :

```
exemple here :

Ou est Charlie ?

![Char][Charlie]

[Charlie]: <img src='/uploads/default/original/1X/70bdb0afec7b129ae882d21587d82d09c2f0a6c3.png'>

```

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 3, 2015, 10:18pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/11 "2015-06-03T22:18:56Z")

</div>

> [@evantill](#):
>
> exemple here :
> 
> Ou est Charlie ?
> 
> ![Char][Charlie]
> 
> [Charlie]: \<img src=‘/uploads/default/original/1X/70bdb0afec7b129ae882d21587d82d09c2f0a6c3.png’\>

Where are you seeing that? I can’t find it.

---

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 10:30pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/12 "2015-06-03T22:30:25Z")

</div>

you need to wait some job maybe this one:

> <https://github.com/discourse/discourse/blob/17d07a8b9a3db9d963f9d7d5bd73504984ef3188/app/jobs/regular/pull_hotlinked_images.rb>

---

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [June 3, 2015, 10:43pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/13 "2015-06-03T22:43:38Z")

</div>

the problem seems to be in this regexp because my link reference is not a number :

> <https://github.com/discourse/discourse/blob/17d07a8b9a3db9d963f9d7d5bd73504984ef3188/app/jobs/regular/pull_hotlinked_images.rb#L66>

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 3, 2015, 11:47pm UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/14 "2015-06-03T23:47:00Z")

</div>

I see we should probably fix that @zogstrip.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 21, 2022, 5:38am UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/15 "2022-07-21T05:38:08Z")

</div>

Took a while, but I believe @david’s rework of this sub system fixed this long standing issue.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 21, 2022, 5:38am UTC](https://meta.discourse.org/t/replacing-remote-images-with-local-uploaded-images-issue/29622/16 "2022-07-21T05:38:10Z")

</div>


