# Downloading remote images doesn't work with protocol-less srcs

**URL:** https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601
**Category:** Bug
**Created:** [January 11, 2017, 5:25pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601 "2017-01-11T17:25:24Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [January 11, 2017, 5:25pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/1 "2017-01-11T17:25:25Z")

</div>

![Long](https://global.discourse-cdn.com/meta/original/3X/9/a/9a3bc7ce270b38e31e0c1425043b3e51539e3b3a.jpg)

The image above, embedded with `![Long](//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/9/a/9a3bc7ce270b38e31e0c1425043b3e51539e3b3a.jpg)` will be downloaded locally, and the image src will be replaced with the new url.

The image below, embedded with `![cat](//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/7/6/7685d7c6a3ecc9df487f7e4c32d3cb4ba571b032.jpg)` won’t, because of the bug.

What happens is the image is correctly downloaded locally, but then the url replacement won’t work, because the code is looking for a src with `http:` prepended to it.

(I’m going to look like a right numpty if this demonstration doesn’t work, but anyway, there’s a fix here: [FIX: Handle img src starting with "//" in pull\_hotlinked\_images job by LeoMcA · Pull Request #4643 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/4643))

 ![cat](https://global.discourse-cdn.com/meta/original/3X/7/6/7685d7c6a3ecc9df487f7e4c32d3cb4ba571b032.jpg)

---

<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: [January 11, 2017, 7:53pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/2 "2017-01-11T19:53:40Z")

</div>

Seems to work fine?

`![cat](upload://krWVHNXXC8AodK54KcKJd2hFeSy.jpeg)`

 ![cat](https://global.discourse-cdn.com/meta/original/4X/8/f/5/8f5451a576933c7aa332c7e84867a5f48ff0c4b6.jpeg)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 11, 2017, 10:53pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/3 "2017-01-11T22:53:34Z")

</div>

@LeoMcA imgur won’t work to prove that here on meta, try with another hosting service.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [January 12, 2017, 5:39pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/4 "2017-01-12T17:39:21Z")

</div>

> [@Falco](#):
>
> @LeoMcA imgur won’t work to prove that here on meta, try with another hosting service.

Aaaah, cheers! The first post now shows the bug, after moving to embedding from the Mozilla Wiki (it was the last place I thought you were going to have blacklisted… and I was right!)

> [@codinghorror](#):
>
> Seems to work fine?

Just to clarify, this is about the behaviour triggered by enabling the `download remote images to local` site setting.

The issue isn’t whether the image is displayed or not, but where it’s hosted. Both images were embedded from the Mozilla Wiki, but only the first has been downloaded locally to your cdn. (The second has been downloaded, but the regexp used to edit the post failed because it was looking for a url with `http:` at the start)

> [@LeoMcA](#):
>
> The image above, embedded with `![Long](//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/9/a/9a3bc7ce270b38e31e0c1425043b3e51539e3b3a.jpg)` will be downloaded locally, and the image src will be replaced with the new url.

This has also exposed another bug, the url in the code block also got replaced. It initially read:

> [@LeoMcA](#):
>
> The image above, embedded with `![Long](https://wiki.mozilla.org/images/2/2e/Longcat1.jpg)` will be downloaded locally, and the image src will be replaced with the new url.

Do we also want to fix this?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [January 12, 2017, 5:49pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/5 "2017-01-12T17:49:53Z")

</div>

> [@LeoMcA](#):
>
> Do we also want to fix this?

Sure if you’re up to it 😉 Beware, there lies 🐉

---

<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: [August 15, 2017, 10:37pm UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/6 "2017-08-15T22:37:38Z")

</div>

Is this still an issue after the massive commonmark refactor @LeoMcA?

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [August 16, 2017, 9:33am UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/7 "2017-08-16T09:33:48Z")

</div>

Let’s see:

 ![Nightly](https://global.discourse-cdn.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png)

`![Nightly|50x50](//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png)`

 ![Nightly](https://global.discourse-cdn.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png)

`![Nightly|50x50](//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png)`

 ![](https://global.discourse-cdn.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png)

`<img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png' width="50" height="50">`

 ![](https://global.discourse-cdn.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png)

`<img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/4/f/4f2567048904a08ba6390cd498a77ec6b9753d0b.png' width="50" height="50">`

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [August 16, 2017, 10:39am UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/8 "2017-08-16T10:39:06Z")

</div>

I don’t think it’s fixed since it’s not a markdown issue but a PostCookedProcessor issue.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [August 22, 2017, 10:26am UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/9 "2017-08-22T10:26:57Z")

</div>

I can’t even get it to trigger remote image downloading - let alone replacing the url in the code block - so I’m not sure what I’m doing wrong.

---

<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: [May 15, 2025, 12:15am UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/10 "2025-05-15T00:15:08Z")

</div>

I think this got fixed by the sands of time, maybe it was @david’s refactor of downloading hotlinked images, I don’t know…

closing, flag to reopen if still an issue that is causing problems.

---

<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: [May 15, 2025, 12:15am UTC](https://meta.discourse.org/t/downloading-remote-images-doesnt-work-with-protocol-less-srcs/55601/11 "2025-05-15T00:15:12Z")

</div>


