Use absolute links for images

If you upload an image to Discourse through the image button, the URL used in the HTML for the topic is relative.

Other Markdown parsers, like GitHub, instead convert all such URLs to absolute.

This would be helpful when pulling markup through the API, for example, as it means the URLs will continue to work and make sense in any context.

Is it?

Your post shows as:

<p dir="ltr">
  If you upload an image to Discourse through the
  <img src="" alt="image" data-base62-sha1="7jwktUgPUE9mp7Jb4gYTYH5wDYj" width="36" height="34"> 
  button, the URL used in the HTML for the topic is relative.

which looks absolute for me.

2 Likes is clearly set up to upload assets to an asset server of some sort. In this case the URL has to be absolute or it wouldn’t work at all.

This is not true for e.g., so I assume it’s not the default. It appears that the default is for assets to be uploaded to the same site and so use a relative URL.

I’m suggesting that relative URLs are never used.

1 Like

So, I’m checking this topic in

<div class="cooked"><p>We’re delighted to bring Ubuntu Desktop 20.10 to the Raspberry Pi 4, completing the Ubuntu family line-up for Raspberry Pi. We encourage you to try it out and give your feedback so we can continue to improve <img src="" title=":chart_with_upwards_trend:" class="emoji" alt=":chart_with_upwards_trend:"> Ubuntu, desktop, server and core, on the Raspberry Pi.</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="//" title="Groovy-Gorilla_WP_1920x1080_RPi.jpg" rel="nofollow noopener"><img src="" alt="Groovy-Gorilla_WP_1920x1080_RPi" data-base62-sha1="bUJ61kFOTd09on4dBLyNSmfKJw0" class="d-lazyload" srcset="//, // 1.5x, // 2x" width="690" height="388"><div class="meta">
<svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use xlink:href="#far-image"></use></svg><span class="filename">Groovy-Gorilla_WP_1920x1080_RPi.jpg</span><span class="informations">1920×1080 143 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use xlink:href="#discourse-expand"></use></svg>
<p>In the video below, we introduce Ubuntu Desktop for the Raspberry Pi, how to set it up and get cracking.</p>
<p><a href="" class="onebox" target="_blank" rel="nofollow noopener"> <span class="badge badge-notification clicks" title="27 clicks">27</span></a></p>
<p>If you prefer, here are tutorials to get you started too:</p>
<p><img src="" title=":woman_student:" class="emoji" alt=":woman_student:"><a href="" rel="nofollow noopener">How to install Ubuntu Desktop on Raspberry Pi 4 <span class="badge badge-notification clicks" title="56 clicks">56</span></a></p>
<p><img src="" title=":man_student:" class="emoji" alt=":man_student:"><a href="" rel="nofollow noopener">How to install Ubuntu Server on your Raspberry Pi <span class="badge badge-notification clicks" title="22 clicks">22</span></a></p>
<p><strong>What applications do you want to see on Raspberry Pi?</strong></p>
<p>While the vast majority of the Ubuntu archive is available for ARM devices, not all developers and ISVs publish ARM builds of their software in the <a href="" rel="nofollow noopener">Snap Store <span class="badge badge-notification clicks" title="7 clicks">7</span></a> or their respective websites. Comment below to let us know what software you’re missing on Raspberry Pi/ARM that you’d most like to see <img src="" title=":eyes:" class="emoji" alt=":eyes:"> made available and we’ll see what we can do.</p>
<p><strong>What HATs are you using?</strong></p>
<p>Raspberry Pi enjoys a rich ecosystem of HATs (Hardware attached on top) and we’re looking to expand the library of available HAT <img src="" title=":tophat:" class="emoji" alt=":tophat:"> modules/drivers in Ubuntu over the coming months. Let us know which HATs you’re using in your projects so we can better understand where to prioritise our work.</p>
<p><strong>Other hardware?</strong></p>
<p>Cameras, displays, GPIO, touch screens, USB accessories, and more. How has your experience been using your existing accessories and peripherals for the Raspberry Pi on Ubuntu?</p>
<p><strong>What are you making with Ubuntu on Raspberry Pi?</strong></p>
<p>Finally, show us that you’re using the Ubuntu Desktop on your Raspberry Pi, or what you’re using it for, for a chance to win some free Groovy Gorilla <img src="" title=":gorilla:" class="emoji" alt=":gorilla:"><img src="" title=":dark_sunglasses:" class="emoji" alt=":dark_sunglasses:"> goodies. Be one of the first to fill out this form: <a href="" rel="nofollow noopener"> <span class="badge badge-notification clicks" title="38 clicks">38</span></a></p></div>

Those appear to be absolute URLs for me.

I have also tested in a test instance I have without a CDN and it appears to be using absolute URLs too.

We also have this feature request Need relative URLs for uploaded images that is asking the opposite of what you are asking, so I’m really confused here.

1 Like

Ah sorry, maybe it was fixed in a recent upgrade, or something else is going on.

I’ll see if I can reproduce the issue we had and get back to you.

1 Like